Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How can i read the lines and store them in an array like following fashion?

by reneeb (Chaplain)
on Oct 19, 2006 at 10:17 UTC ( [id://579318]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://579318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-03-28 22:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found