Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Combining Duplicate entries in an Array

by mmartin (Monk)
on Feb 22, 2012 at 20:18 UTC ( #955611=note: print w/ replies, xml ) Need Help??


in reply to Re: Combining Duplicate entries in an Array
in thread Combining Duplicate entries in an Array

Ok, so I modified you example a little bit. Didn't change anything except the way it's structured. The way you did it makes sense but is a little hard for me to read, and possibly maintain later if I ever have to change something.

Here is what I modified to:

for (my $x = $#temp; $x >= 0; $x--) { if ( substr($temp[$x-1][0], 0, -1) eq substr($temp[$x][0], 0, -1)) { $temp[$x-1][1] += $temp[$x][1]; splice @temp, $x, 1; } }
Does the same thing just a little more long winded and simpler for a noob..


Thanks Again for Your Help,
Matt


Comment on Re^2: Combining Duplicate entries in an Array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-07-14 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (253 votes), past polls