in reply to textwrap of file
local $/= undef; # read entire file at once my @text=<FH>;
Here, you now have to split up your data as you see fit. By doing what you have done, you are slurping the whole of the contents of the file into the first element of the array. To see this, run the following program on a test file and uncomment the 'local' line:my $data; open(FH,'<',$file) || die "Oops $!"; local $/ = undef; $data = <FH>; close(FH);
use strict; use warnings 'all'; # Uncomment this to see what I mean # local $/ = undef; open(FH,'<',"test.txt") || die "oops: $!"; my @data = <FH>; close (FH); print $data[0];
|
|---|