SPUG: Dup'ing STDIN from DATA?
Joel Grow
largest at largest.org
Thu Mar 15 12:32:14 CST 2001
Lauren Smith wrote:
> Works for me:
>
> #!perl -w
>
> open STDIN, "<&DATA";
>
> while (<STDIN>) { # no arguments provided to script
> s/.*? //;
> print $_;
> }
>
> __DATA__
> Stuff here
>
> Output:
> here
>
> Is Perl making a distinction between "<>" and an explicit "<STDIN>"?
It shouldn't--<> should check @ARGV and if it's an empty list set $ARGV[0]
to '-', which is STDIN.
I noticed that this code works on 5.6 but not on 5.004_04, so I thought
Tim might have been running it on an older version of Perl.
Joel
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list