SPUG: Dup'ing STDIN from DATA?

Tim Gim Yee tgy at chocobo.org
Fri Mar 16 03:19:06 CST 2001


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' }

> s/^(.*?:)//;
> defined $1  and  print "Extracted $1\n";
> 
> __DATA__
> Data: right here


-- 
Tim Gim Yee
tgy at chocobo.org



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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