use strict;
use warnings;
my %seen;
my @array = (["1", "1", "3"], ["1", "5", "6"], ["1", "1", "3"]);
my @unique = grep {! $seen{$_->[1]}++} @array;
print "@$_\n" for @array;
print "\n";
map {$_++} @$_ for @unique;
print "@$_\n" for @array;
print "\n";
Prints:
1 1 3
1 5 6
1 1 3
2 2 4
2 6 7
1 1 3
where you wanted @array unaffected by the manipulation of the contents of @unique. If you know that you are dealing with an AoA then you can:
use strict;
use warnings;
my %seen;
my @array = (["1", "1", "3"], ["1", "5", "6"], ["1", "1", "3"]);
my @unique = map {[@$_]} grep {! $seen{$_->[1]}++} @array;
print "@$_\n" for @array;
print "\n";
map {$_++} @$_ for @unique;
print "@$_\n" for @array;
print "\n";
print "@$_\n" for @unique;
print "\n";
Prints:
1 1 3
1 5 6
1 1 3
1 1 3
1 5 6
1 1 3
2 2 4
2 6 7
Note the map used with the result from grep to copy the elements of each unique row? So actually rather than using neither grep nor map, what you really needed was to use both grep and map!
Perl reduces RSI - it saves typing
|