SPUG: Dup'ing STDIN from DATA?

Alex Leites Alex.Leites at esca.com
Thu Mar 15 12:43:36 CST 2001


It works if you use INIT block instead of BEGIN.

Alex

-----Original Message-----
From: Tim Maher/CONSULTIX [mailto:tim at consultix-inc.com]
Sent: Thursday, March 15, 2001 10:22 AM
To: spug-list at pm.org
Subject: SPUG: Dup'ing STDIN from DATA?




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/



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