|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
On Wed, Jan 21, 2004 at 06:00:15PM -0500, Phil Lawrence wrote:
> [40 lines, 135 words, 858 characters] Top characters: -eosirnh
>
> I'd like to run through (<>) once, note some things, and then run
> through it again.
>
> I'd like to do something like this:
> --------------------------------
> my @fh;
> while (<>) {
> foo();
>
> # check eof for each file processed
> # by (<>)
> if (eof) {
> if ($ARGV ne '-') {
> # save fh for later reopening
> push @fh, $ARGV;
> } else {
> # reset position in STDIN stream
> seek(ARGV,0,0);
> last;
> }
> }
> }
>
> # reuse all the stuff (<>) went through before
> if (@fh) {
> ...
> }
> if (tell STDIN) {
> ...
> }
I think you're being too clever by far!
If you're calling it stdin, behave like it's stdin, which is not
rewindable. Either read it in in arrays (my @lines = <>;) if you know
you'll have enough memory or else explicitly open files that you can
rewind.
--
Jeff
Jeff Abrahamson <http://www.purple.com/jeff/>
GPG fingerprint: 1A1A BA95 D082 A558 A276 63C6 16BF 8C4C 0D1D AE4B
-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|