in reply to Join unless $var has already been joined?
What you want is to eliminate duplicate elements from a list. Here's one solution, from the Perl cookbook (via RE: Return a Unique Array):
my %seen =() ; @unique_array = grep { ! $seen{$_}++ } @non_unique_array ;
Put that into a sub:
and you can simply dosub dedup { my %seen; grep { ! $seen{$_}++ } @_; }
to join tapes together with no duplicates.@tapes = qw(tape1 tape2 tape1 tape3 tape2 tape1); print join(' ',dedup(@tapes)),"\n";
|
|---|