Thank you all for your help; all suggestions were welcome and helpful.

I didn't give the full details but Jim's solution did what I wanted the
best and after reading around I think I get it. I've sat here trying to
"break" it for the past half an hour and so far so good.

I solemnly swear to properly learn hashes and use them (and to stop
thinking of them as "weird").

Again, thank you for the help! It's very appreciated.

James.

On Tue, Feb 9, 2016 at 6:37 PM, Jim Gibson <jimsgib...@gmail.com> wrote:

>
> > 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