in reply to __DATA__, seek, and tell

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: __DATA__, seek, and tell
by gamache (Friar) on Oct 16, 2007 at 15:50 UTC
    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.