Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Extracting non-consecutive but related items from an array.

by sapnac (Beadle)
on Jun 15, 2005 at 14:11 UTC ( #466922=note: print w/replies, xml ) Need Help??


in reply to Re: Extracting non-consecutive but related items from an array.
in thread Extracting non-consecutive but related items from an array.

#use strict; use FileHandle; # Global Declaration my($spool,%serverdet); open (spooler ,"data.dat") or die "Error opening the file\n"; while($spool=<spooler>) { chomp($spool); ($server,$dat1,$dat2)=split(/,/,$spool); if($serverdet{$server}) { $serverdet{$server} .= ";".$dat1.",".$dat2; }else{ $serverdet{$server} = $dat1.",".$dat2; } } foreach $key (sort keys %serverdet) { print "Server $key\n"; @val = split(/;/,$serverdet{$key}); foreach $val (sort @val) { print $val."\n"; } }
Hope this helps!

code tags added by holli

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://466922]
help
Chatterbox?
[1nickt]: For multiple dirs use iterator(): $it = path("/foo")-> iterator; while ( my $path = $it->() ) {...}
[1nickt]: (also skips . and .. automatically, and follows subdirs if you set <c\>recurse => 1</c>
[1nickt]: $it = path("/foo")-> iterator(recurse => 1 );

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2017-03-28 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (340 votes). Check out past polls.