smackdab has asked for the wisdom of the Perl Monks concerning the following question:
Basically I can't figure out how to pass a filehandle and then copy it. I expect that the copy can move the filepointer w/o affecting the original filehandle, but I can't really figure that out either...In this test, it seems that LOG and TEMPLOG are equal and I really want them to be able to point to different parts of the log file... I am just getting back in to Perl and am quite rusty ;-)use strict; use warnings; sub GetLogHeader { open(TEMPLOG, "<&LOG"); while (my $row = <TEMPLOG>) { print "$row\n"; last; } close(TEMPLOG); } my $abc; open(LOG, "c:\\log.log") || die; $abc = <LOG>; my $header = GetLogHeader(\*LOG); $abc = <LOG>; $abc = <LOG>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: duping a filehandle
by ikegami (Patriarch) on Jan 14, 2007 at 03:58 UTC | |
by smackdab (Pilgrim) on Jan 14, 2007 at 05:02 UTC | |
by ysth (Canon) on Jan 14, 2007 at 22:38 UTC |