May not be the best practise in the world, but this works like you asked.
'foo' returns array, and 'if' statement looks like
if ((($r,$m) = foo($i))[0]) {
Example:
#!/usr/bin/perl
use strict;
my ($m, $r);
foreach my $i (1 .. 2) {
print "\n";
if ((($r,$m) = foo($i))[0]) {
print "It worked\n";
}
else {
print "error: $m\n";
}
}
sub foo {
my $num = shift;
my @ret = ();
if ($num == 1){
print "inside foo, good\n";
@ret = ($num,"good input number");
}
else {
@ret = (0,"bad input number");
}
return @ret;
}