in reply to Jumping out of a partially read file
Since you say that there is a special marker signifying the end of the header section, you may also be able to save yourself some time and trouble by setting $/ to that marker. Then you won't even need to loop. To read the header section and nothing else, do this:
Now your header section is contained in $header. Hope this helps!local $/ = '<END_OF_HEADERS>'; # change this to what the marker really + is open FILE, $file or die "Couldn't open '$file': $!\n"; my $header = <FILE>; close FILE;
|
|---|