in reply to Extracting non-consecutive but related items from an array.
This is just the thing hashes exist for:
#Untested use strict; my %data; #assume file is opened as <INPUT> while (<INPUT>) { chomp; my ($server,@apps_info)=split /,/; push @{$data{$server}}, \@apps_info; } foreach my $server ( keys %data ) { print "$server\n\t"; for ( @{$data{$server}} ) { print join " ", split /,/; print "\n\t"; } }
Basically, pull all of the data into a hash with the server name as keys.
Update: Updated as per Tomtom's remark
CU
Robartes-
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Extracting non-consecutive but related items from an array.
by Tomtom (Scribe) on Jun 15, 2005 at 08:59 UTC | |
by robartes (Priest) on Jun 15, 2005 at 09:18 UTC | |
by blackadder (Hermit) on Jun 15, 2005 at 09:29 UTC | |
by robartes (Priest) on Jun 15, 2005 at 09:46 UTC | |
by Anonymous Monk on Jun 15, 2005 at 13:43 UTC |
In Section
Seekers of Perl Wisdom