in reply to return from subfunction

I think your case is well defined, as long as your strings don't look like a negative number. (you should change your regex to /^-\d$/).

But for a general pattern I prefer to flag error condition with an empty list, and to use a list assignment. Like this you can still return undef or an empty string in a boolean context (thats especially good for iterators)

(see semipredicate problem)

You can use one of the special vars for errors ($! $@ ...) to tunnel the message or just define your own special var in a dedicated namespace like $Error::message. (like this you're free to add as many informations as you want)

for (1..4){ print "$_: "; if ( ($str) = func($_) ) { # list assignment only false for empty li +st print "Success $str\n"; } else { print "Error $Error::message"; } } sub func { $Error::message="Wrong wrong wrong!!"; goto "L".shift; L1: return ""; L2: return 0; L3: return undef; L4: return; # blank returns empty list } __DATA__ 1: Success 2: Success 0 Use of uninitialized value $str in concatenation (.) or string at /tmp +/tst2.pl line 4. 3: Success 4: Error Wrong wrong wrong!!

Frankly I don't understand this culture to rely on returning false scalars...

Of course jdporters pattern with exceptions is slightly cleaner, but this pattern fits better into the standard pattern to simultaniously execute and check within a boolean context (if,unless,while,until, and,...)

Cheers Rolf

UPDATE: extended code example