Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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


Comment on Re^2: Extracting non-consecutive but related items from an array.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://466922]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (19)
As of 2015-07-31 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls