develooper Front page | perl.beginners | Postings from February 2002

RE: Module call/stdin

Thread Previous
From:
Timothy Johnson
Date:
February 22, 2002 22:11
Subject:
RE: Module call/stdin
Message ID:
C0FD5BECE2F0C84EAA97D7300A500D5002580FC2@SMILEY
 
     If I understand your question correctly, then all you want to do is
iterate through a list, performing some action on each item.  You can just
use a foreach loop for this:

foreach $file(@files){
   Module::Function($file){
      do something...
   }
}

unless you actually want to do something to the file, in which case it would
look more like this:

foreach $file(@files){
   open(INFILE,$file);
   while(<INFILE>){
      Module::Function($_);
   }
}

or are you saying that the module normally gets its parameters from <STDIN>,
and you want to redirect the output of one part of the script so that the
module thinks it's actually coming from user input?

-----Original Message-----
From: Chip Dunning
To: beginners@perl.org
Sent: 2/22/02 9:58 PM
Subject: Module call/stdin

I am definitely new to Perl - so here is my basic question.

I have a module called from a script. I want the script to call the
module
and pass it a filename. The module will use that filename in the same
manner
as if it came from the command like (ex.  while (<>) { .... } ).


Chip



-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About