in reply to Trying to do multiple while loops on the same input file
Is this behavior intentional? Yes. In Perl files work about the same way they work in most languages. You open a file and then you read from start to end. Once you are at the end you can't read anymore unless you perform a seek.
Should I have known this to begin with? Hard to say. Let's just say that it is good that you know it now.
Does this behavior serve any purpose or have any benefit? Yes. It encourages "one-pass" processing of files. In other words it is more efficient to only read a file once (start to end). Structuring your code so that you don't need to make multiple passes through a file will make your program consume less resources and will most likely make your program more efficient.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to do multiple while loops on the same input file
by elef (Friar) on Jun 01, 2011 at 14:17 UTC | |
by zek152 (Pilgrim) on Jun 01, 2011 at 14:28 UTC | |
by elef (Friar) on Jun 01, 2011 at 15:07 UTC | |
by zek152 (Pilgrim) on Jun 01, 2011 at 15:28 UTC | |
by armstd (Friar) on Jun 01, 2011 at 15:14 UTC |