You should maybe look up the wantarray documentation, since it seems it could be very relevant here. In case you don't know, it lets a function determine what context it has been called in (list, scalar or void). Handy when you want to be able to respond differently to different calling contexts ... or even just raise an error/warning when called with the wrong context, eg:
sub pedantic_syswrite {
my $context=wantarray;
if (defined ($context)) {
if ($context) { # caller wants an array, which is (mostly) silly f
+or write
die "write doesn't return an array, silly!\n";
} else { # scalar context
# no warning, because user should always check return value
syswrite @_;
}
} else { # void context
die "I'm not going to write if you don't check my return value\n";
}
}
So, ok, maybe the code shouldn't die when called in a list context :-/ But it demonstrates how you
might use it.