Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 ( #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);
  • Comment on Re: How can i read the lines and store them in an array like following fashion?
  • Download Code

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
Node Status?
node history
Node Type: note [id://579318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2019-12-07 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (160 votes). Check out past polls.

    Notices?