SPUG: Dup'ing STDIN from DATA?
Lauren Smith
LaurenS at bsquare.com
Thu Mar 15 12:20:59 CST 2001
> -----Original Message-----
> From: Tim Maher/CONSULTIX [mailto:tim at consultix-inc.com]
> Sent: Thursday, March 15, 2001 9:58 AM
> To: spug-list at pm.org
> Subject: Re: SPUG: Dup'ing STDIN from DATA?
>
> For those put off by the AWKisness (-n usage) of the above program,
> the following one doesn't work any better:
>
> #! /usr/bin/perl -w
>
> open STDIN, "<&DATA";
>
> while (<>) { # no arguments provided to script
> <do fun stuff with $_>
> }
>
> __DATA__
> Stuff here
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>"?
Lauren
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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