Front page | perl.beginners |
Postings from March 2002
Re: string indexing
Thread Previous
From:
John W. Krahn
Date:
March 4, 2002 16:12
Subject:
Re: string indexing
Message ID:
3C840D70.BADDEC1C@acm.org
Bob Ackerman wrote:
>
> On Monday, March 4, 2002, at 12:15 PM, John W. Krahn wrote:
> >
> > print +(split //, "abcd")[1], "\n";
>
> now that is clever! what is the literal meaning/function of the '+'.
> of course, one still must know that a leading paren will be seen by 'print'
> unless there is some intervening dummy character. that's ok.
perldoc -f print
[snip]
Because print takes a LIST,
anything in the LIST is evaluated in list context,
and any subroutine that you call will have one or
more of its expressions evaluated in list context.
Also be careful not to follow the print keyword
with a left parenthesis unless you want the corre
sponding right parenthesis to terminate the argu
ments to the print--interpose a `+' or put paren
theses around all the arguments.
John
--
use Perl;
program
fulfillment
Thread Previous