my @a = qw(4444 22 1 22 333); my $shortest; my $min; for ( @a ) { my $l = length($_); if (not defined $min or $l<$min ) { $min=$l; $shortest=$_; } } print $shortest;