#!/usr/bin/perl use strict; use warnings; use List::Util qw (uniq); # I think this is the fastest way for the trim functionality... # 2 statements benchmark faster than one statement sub myTrim { my $str = shift; #shift faster than @_ for one paramater $str =~ s/^\s*//; #no space at front $str =~ s/\s*$//; #no space at rear return $str; } my @fileTags = map{myTrim($_)}@fileTags. @fileTags = uniq @fileTags; #### #!/usr/bin/perl use strict; use warnings; use List::Util qw (uniq); sub myTrim { my ($str) = @_; my ($trimmed) = ($str =~ /\s*(.*)\s*/); return $trimmed; } my $x = "x "; $x = myTrim($x); print "$x!\n"; #prints "x !"