> On Feb 9, 2016, at 6:46 AM, James Kerwin <jkerwin2...@gmail.com> wrote:
> 
> Thank you both very much for your help. I'll investigate this way when I get 
> home later (I'm a bit wary of hashes because they're weird).

Here is a solution using a hash:

#!/usr/bin/perl
use strict;
use warnings;

my @array = qw{
   111111_
   222222_
   222222_
   333333_
   333333_
   333333_
   444444_
   444444_
   555555_
};

my %count;
for my $element ( @array ) {
  $element .= ++$count{$element};
}

print "Array:\n\n  ". join("\n  ",@array) . "\n”;

__END__

Note that the array needn’t be sorted for this method to work.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to