SPUG: Dup'ing STDIN from DATA?
ced at carios2.ca.boeing.com
ced at carios2.ca.boeing.com
Thu Mar 15 14:37:58 CST 2001
> A dup needs to adjust to DATA's start position.
> my $start = tell DATA; # see where DATA is positioned initially
> open(STDIN, "<&DATA") # comment-out after testing
> or die "dup failed: $!";
> seek(STDIN, $start, 0) or die "can't seek"; # re-position to DATA start
>...
Above is true for 5.5 versions but several others
others have pointed out that this'll work for 5.6
if DATA filehandle is opened in an INIT or a CHECK.
The BEGIN won't work at all though:
>From perldata:
Note that you cannot read from the DATA filehandle in a
BEGIN block: the BEGIN block is executed as soon as it is
seen (during compilation), at which point the corresponding
__DATA__ (or __END__) token has not yet been seen.
Rgds,
--
Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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