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

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

Thread Previous
From:
Lukas Mai
Date:
May 27, 2013 04:20
Subject:
Re: [perl #70357] duff DATA segment in -e
Message ID:
51A2DE78.2010103@gmail.com
On 27.05.2013 03:07, James E Keenan via RT wrote:
> On Mon Nov 09 08:33:58 2009, zefram@fysh.org 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 
escapes.

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

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

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

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About