develooper Front page | perl.beginners | Postings from March 2002

Re: string indexing

Thread Previous
John W. Krahn
March 4, 2002 16:12
Re: string indexing
Message ID:
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
                         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.

use Perl;

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About