SPUG: Dup'ing STDIN from DATA?

Matt Tucker tuck at whistlingfish.net
Fri Mar 16 12:03:11 CST 2001


-- Tim Gim Yee <tgy at chocobo.org> spake thusly:

> On Thu, 15 Mar 2001, Tim Maher/CONSULTIX wrote:
> 
>> I'm writing a little program that will eventually read input from
>> SDTIN, but initially I want to test it using the DATA filehandle.
>> I thought the following would work, but it doesn't; it just reads
>> from STDIN.  Anybody know the way to accomplish this?
>> 
>> #! /usr/bin/perl -wn
>> 
>> BEGIN {
>> 	open STDIN, "<&DATA";	# comment-out after testing
>> }
> 
> Reading from <>, maybe you want to dup ARGV instead of STDIN.
> 
>     BEGIN { @ARGV = '<&DATA' }

You're talking nonsense here. This would place '<&DATA' into the array
@ARGV, which would presumably cause Perl to try to open an actual file
named '<&DATA' when it got to 'while (<>)'. I haven't even tried this,
and I'd be shocked if it did anything like what you expect.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20010316/7ac9a1fd/attachment.bin


More information about the spug-list mailing list