in reply to proccessing file paragraphs -braindead i am ..

I can see you are used to shell programming :-)

You're probably better off using an array:

$/ = ":::\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++; }
Which also eliminates the need for counting the records in advance..

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
    Thank you both. and yes I am used to shell scripting , dont know how to shake that one off ..... barazani