You are wrong about being able to reset the read position in DATA -- the code I posted works fine, I just wanted to know if I were breaking rules. Try this sample program:
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
my $datapos = tell DATA;
while (<DATA>) {
print;
}
seek DATA, $datapos, 0;
}
__DATA__
foo
bar
baz
Your data here!
Add, remove, or change lines while running the program.
Every time you hit Return, you will see the current contents of DATA.
This, by the way, is going into a Perl module. |