in reply to Re: Re: Guess, what following simple oneliner print:
in thread Guess, what following simple oneliner print:

BUU and moxliukas are spot on with regards to the ' being the old package delimiter - However with regards to the => operator and the quotes, the use of this operator is synonymous with the comma operator which in the scalar context, evaluates the left argument. This means that the This'is'it code is evaluated prior to being printed within the interpolated quotation marks.

For a further explanation on this, see perlop under the heading "Comma Operator".

 

Replies are listed 'Best First'.
Re: Re: Re: Re: Guess, what following simple oneliner print:
by domm (Chaplain) on Jul 22, 2002 at 10:26 UTC
    However with regards to the => operator and the quotes, the use of this operator is synonymous with the comma operator which in the scalar context, evaluates the left argument.

    But print allways uses list context. So print doesn't get the string 'This::is::it', but a list consisting of  'This::is::it', '', '', which still evaluates to 'This::is::it'

    Try this:

    perl -we "print test'bla=>$/"

    You'll see that the value of $/ will be printed, as => is just another comma operator, so the above is the same as

    perl -we "print test'bla,$/"

    You can pack in even more commas:

    perl -we "print test'bla=>=>=>=>=>''"

    (BTW, I've been using the single-quote-as-package-delimiter trick for quite some time in my .sig>

    -- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}