perl/script and retval

Warren Block wblock at wonkity.com
Sun Apr 8 19:03:44 UTC 2007


On Sun, 8 Apr 2007, Olivier Regnier wrote:

> my $retval=0;
> my $doc_supfile="/etc/doc-supfile";
>
> # Downloading doc files
> print "===> Downloading doc files\n";
> system("/usr/bin/csup $doc_supfile
> if (! $retval) {
> print "abort";
> exit;
> }
> I don't know what happened with retval but that doesn't work correctly.

Hint: does $retval have a return value assigned to it anywhere?

Even then, it may not work like you expect.  That is explained:

perldoc -f system

In general, 'perldoc -f functionname' is very useful.  Also, see

perldoc perlstyle

So that code section would be better (more Perlishly) done like this:

--
my $doc_supfile="/etc/doc-supfile";

# Downloading doc files
print "===> Downloading doc files\n";
system("/usr/bin/csup $doc_supfile") == 0 or die "abort: $?\n";
--

-Warren Block * Rapid City, South Dakota USA


More information about the freebsd-questions mailing list