#!/usr/bin/perl -w use strict; use warnings; my @TEST_VALUES = ('55a', 'a55'); foreach my $i (@TEST_VALUES) { print "Calling TEST('$i'): "; print "\nTEST return value = ", TEST($i), "\n"; } exit; ####################################### sub TEST { print " TEST() was called "; defined $_[0] or return 0; my $N = shift; print "with argument: '$N'\n"; # If we get a warning, it's probably because $N # is not a number. So, we remove all non-digits # and then it becomes a number! local $SIG{__WARN__} = sub { print "\t\t(((warning '$N'->"; $N =~ tr|0-9||cd; $N = "0$N"; print "'$N')))\n"; }; $N += 0; print "\nThe value of N is now '$N'\n"; return int($N); }