in reply to proccessing file paragraphs -braindead i am ..
You're probably better off using an array:
Which also eliminates the need for counting the records in advance..$/ = ":::\n"; # define ::: as paragraph delimiter open(HOSTDB,"hostdb") or die "cannot open hostdb: $!"; while (<HOSTDB>) { chomp; push @records,map( { { split/:/ } } split/\n/ ); # updated to make + hashrefs.... close HOSTDB; my $count = 0; for my $rec (@records) { print "record $count\n"; print "hostname: $rec->{hostname}\n"; print "ip: $rec->{ip}\n"; $count++; }
By the way; if you are not using the info anywhere else, you could also just print it as you go, instead of storing the records in the array.
Update: Added extra { } to map.
-- Joost downtime n. The period during which a system is error-free and immune from user input.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: proccessing file paragraphs -braindead i am ..
by barazani (Initiate) on Dec 13, 2002 at 15:50 UTC |