develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #70357] duff DATA segment in -e

Thread Previous
Lukas Mai
May 27, 2013 04:20
Re: [perl #70357] duff DATA segment in -e
Message ID:
On 27.05.2013 03:07, James E Keenan via RT wrote:
> On Mon Nov 09 08:33:58 2009, wrote:
>> $ perl -we $'print <DATA>;\n__DATA__\nfoo\n'
>> $
> I'm afraid I don't understand the '$' in the above command, i.e., I
> don't know what it is supposed to be doing.  And I can't find anything
> like that in 'perlrun'.
> Can you clarify?

You won't find it in perlrun because it's a shell thing (might be a 
bashism). $'...' is a quoted construct that doesn't expand contained 
$variables or `commands` but does understand C (and Perl) like backslash 

$ echo $'foo\n\tbar\'\nbaz\\'

Zefram's code can be rewritten without $'...' like this:

$ perl -we 'print <DATA>;' -e '__DATA__' -e 'foo'

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