in reply to value returned on m// failure
$a = 123; print $a =~ m/^\d+$/, "\n"; $a = "abc"; $ret = ($a =~ m/^\d+$/); if (defined($ret)) { print "=$ret=\n";#print out == } else { print "undef";#not going this loop }
sub true_false { if (shift()) { print "true\n"; } else { print "false\n"; } } true_false("a"); true_false(1); true_false(""); true_false(0); if (undef) { #I don't want to use true_false for this case, so it is g +uranteed that shift() does not play any magic print "true\n"; } else { print "false\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: value returned on m// failure
by parv (Parson) on Dec 31, 2002 at 01:33 UTC | |
by pfaut (Priest) on Dec 31, 2002 at 01:41 UTC | |
by parv (Parson) on Dec 31, 2002 at 05:15 UTC | |
by MarkM (Curate) on Dec 31, 2002 at 04:50 UTC | |
by parv (Parson) on Dec 31, 2002 at 05:41 UTC | |
by pg (Canon) on Dec 31, 2002 at 01:39 UTC |