Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Combining Duplicate entries in an Array

by JavaFan (Canon)
on Feb 22, 2012 at 21:17 UTC ( [id://955625]=note: print w/replies, xml ) Need Help??


in reply to Combining Duplicate entries in an Array

Untested code:
my @copy = $AP_NumClients[0]; for (my $i = 1; $i < @AP_NumClients; $i++) { my $id = $AP_NumClients[$i][0]; if ($id =~ s/\.1$/.0/ && $id eq $copy[-1][0]) { $copy[-1][1] += $AP_NumClients[$i][1] } else { push @copy, $AP_NumClients[$i]; } } @AP_NumClients = @copy;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-24 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found