in reply to How can i read the lines and store them in an array like following fashion?
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array; { local $/ = "\nITEM"; open my $fh,'<','./item.txt' or die $!; while(my $entry = <$fh>){ chomp $entry; $entry = 'ITEM'.$entry unless $entry =~ /^ITEM/; push @array,[split /\n/,$entry]; } close $fh; } print Dumper(\@array);
|
---|
Replies are listed 'Best First'. | |
---|---|
A reply falls below the community's threshold of quality. You may see it by logging in. |
In Section
Seekers of Perl Wisdom