Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

rewinding an input filehandle

by Anonymous Monk
on Jul 28, 2005 at 19:16 UTC ( #479097=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks!
How do I rewind an input filehandle without having to close and reopen it?

Thanks.

Comment on rewinding an input filehandle
Replies are listed 'Best First'.
Re: rewinding an input filehandle
by ketema (Scribe) on Jul 28, 2005 at 19:23 UTC
    I think perldoc -f seek
    should help you out
Re: rewinding an input filehandle
by chas (Priest) on Jul 28, 2005 at 19:30 UTC
    You can use seek, e.g. seek F,0,0 to reset to the beginning of the file.
    chas
Re: rewinding an input filehandle
by mugwumpjism (Hermit) on Jul 29, 2005 at 00:42 UTC

    There is also IO::Handle::ungetc for small rewinds on streams.

    $h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://479097]
Approved by Tanalis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-08-03 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (19 votes), past polls