Urvashi Mishra wrote:
>
> hi;
Hello,
> i am trying to take input from multiple files....
> Various I/P files are specified at command line...
>
> Can anyone tell me how to pass the file name to a
> routine that opens it for parsing ....
>
> the same function is to be called for all the I/P
> files...
>
> Code is:
>
> foreach my $file (@ARGV)
> {
> #my $file= shift @ARGV;
> #print "$file\n";
> #
> &pass1($file);
> &display();
> print " \n ****8next******\n";
> }
>
>
> and the function to be called is
>
> sub pass1
> {
> my ($file)[EMAIL PROTECTED];
> print "$file";
> #MIBFH++;
> open(MIBFH,$file)|| die "Error opening the $file
> $!\n";
> while(my $line = <MIBFH> )
> {
> ....
> }
> close(MIBFH);
>
> }
>
> Can anyone help me...!
How about something like this:
while ( <> ) { # process files in @ARGV
if ( $. == 1 ) {
print "File name: $ARGV\n";
}
# process the contents of the file
if ( eof ) {
close ARGV; # reset $. for next file
print " \n ****8next******\n";
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>