SPUG: Dup'ing STDIN from DATA?

Tim Maher/CONSULTIX tim at consultix-inc.com
Thu Mar 15 11:43:54 CST 2001


SPUGsters,

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
}

s/^(.*?:)//;
defined $1  and  print "Extracted $1\n";

__DATA__
Data: right here

*==========================================================================*
|  Dr. Tim Maher, CEO, Consultix        (206) 781-UNIX/8649;  ask for FAX# |
|  Email: tim at consultix-inc.com         Web: http://www.consultix-inc.com  |
|  TIM MAHER: Unix/Perl   DAMIAN CONWAY: Adv. Perl   COLIN MEYER: Perl/DBI |
|  *We are currently scheduling On-Site Classes on UNIX and Perl topics!*  |
*==========================================================================*

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