SPUG: Dup'ing STDIN from DATA?
ced at carios2.ca.boeing.com
ced at carios2.ca.boeing.com
Thu Mar 15 13:49:20 CST 2001
> #! /usr/bin/perl -wn
>
> BEGIN {
> open STDIN, "<&DATA"; # comment-out after testing
> }
>
> s/^(.*?:)//;
> defined $1 and print "Extracted $1\n";
>
> __DATA__
> Data: right here
A dup needs to adjust to DATA's start position.
Rgds,
--
Charles DeRykus
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
$_ = <STDIN>;
s/^(.*?:)//;
defined $1 and print "Extracted $1\n";
__DATA__
Data: right here
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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