[EMAIL PROTECTED] wrote:
> After I use <> operator on s file handle, I need read it from head again. I
> found these is no rewind function, must I close it and open again?

That depends.  If <> is reading from '-' (STDIN) then there is no "file" to
rewind.  If @ARGV contains multiple file names then do you want to rewind each
file or all files at the same time?

Assuming that you have a single file and a valid filehandle:

use Fcntl qw[ :seek ];

while ( <$fh> ) {
    # do something
    }

seek $fh, 0, SEEK_SET or die "Cannot seek on file $file: $!";

while ( <$fh> ) {
    # do something else
    }

close $fh;



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>


Reply via email to