Hello there!
I'm a novice perl programmer and I'm trying to pass a
File-Handle to two different subroutines one after the
other as follows
#!/usr/bin/perl -w
use strict;
my $FH;
open($FH, "filename") || die "Could not open file!
n";
func_one(*$FH);
func_two(*$FH);
exit(0);
sub func_one
{
local * FH = $_[0];
my $line;
while(defined($line = <$FH>))
{
printf($line);
}
}
sub func_two
{
local * FH = $_[0];
my $line;
while(defined($line = <$FH>))
{
printf($line);
}
}
Problem is first function(func_one) works fine,
while second does nothing. My guess is that
file-handle is reaching at the end of the file in
func_one and thus there remains nothing for func_two
to read in.
Could someone tell me how can I make both of
them(func_[one/two]) work without openning the file
twice in two functions?
Regards
-Prasad
PS: Please don't send me html/attachment/Fwd mails
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com