Mark Dominus on 22 Jan 2004 01:22:11 -0000 |
> I'd like to run through (<>) once, note some things, and then run > through it again. In general, the only way is to store all the data in memory, because <> may want to read standard input, and standard input might be attached to a pipe, and once you've read the data from the pipe, it's gone. So probably the easiest thing to do that always works would be @input = <>; for (@data) { # process once } for (@data) { # process again } Of course the drawback of this is that you store all the data in memory, even when you don't have to. If you don't have to worry about pipes, then it seems to me that the easiest thing to do is this: @saved_ARGV = @ARGV; while (<>) { # process once } @ARGV = @saved_ARGV; while (<>) { # process again } This has low memory cost but fails if the input is a pipe, socket, terminal device, or such like. > I'd like to do something like this: Sorry, I can't really make head or tail of this code. I hope this was helpful anyway. - **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|