sub array_to_string # -------------------------------------------------------------- # Joins an array's values without the warning for uninitized # elements. Also, replaces undef values with an appropriate # string. # -------------------------------------------------------------- { my @values = @_; my $output = ""; for (@values) { $output .= defined $_ ? $_ : "undef"; # comment this out if you don't want trailing spaces. $output .= " "; } return $output; } sub get_array_index # -------------------------------------------------------------- # When given a scalar and an array, this either returns the # of the scalar in the array or -1 (not found). # -------------------------------------------------------------- { my $value = shift; my @values = @_; for my $index ( 0 .. $#values ) { return $index if $value eq $values[ $index ]; } }