perl.beginners
[Top] [All Lists]

Re: __DATA__ in command line

Subject: Re: __DATA__ in command line
From: John W. Krahn
Date: Thu, 05 Nov 2009 20:05:48 -0800
Newsgroups: perl.beginners


À¼»¨ÏÉ×Ó wrote:
Hello,

Hello,

doesn't one-liner Perl command support __DATA__ handler?

No.  It only works in an actual file located on a real file system.


Just found this:

# perl -e 'while(<DATA>){ print }
__DATA__
abc
123
def
'

run without any output.

You could always do it like this:

perl -e'
my $data = <<DATA;
abc
123
def
DATA
open FH, "<", \$data or die $!;
print while <FH>;
'


John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

<Prev in Thread] Current Thread [Next in Thread>