hostname:host1 ip:192.168.1.1 cpu:PIII other info:fjfjfjfjfjjf ::: hostname:host2 ip:192.168.1.2 cpu:PIII other info:fjfjfjfjfjjf ::: hostname:host2 ip:192.168.1.2 cpu:PIII other info:fjfjfjfjfjjf ::: #### #!/usr/bin/perl -w use diagnostics; $/ = ":::\n"; # define ::: as paragraph delimiter #figure out how many paragraphs are there ? open(HOSTDB,"hostdb") or die "cannot open hostdb"; $record = 0; while(){ $record++; } print "number of records - $record\n"; close(HOSTDB); open(HOSTDB,"hostdb") or die "cannot open hostdb"; $host1 = ; $host2 = ; $host3 = ; close(HOSTDB); chomp($host1); chomp($host2); chomp($host3); #this is just for me to see what's been proccessed ... #print "paragraph1 = $host1"; #print "--------------------------\n"; #print "paragraph2 = $host1 "; #print "--------------------------\n"; #print "paragraph3 = $host1 "; #print "--------------------------\n"; foreach( $host_record = 1 ; $host_record <= $record ; $host_record++ ){ print "------host.$host_record--------\n"; $field = 0; for $field (split /\n/, ${"host".$host_record}) { print "Field contains: `$field'\n"; } }