Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Apr 2007 13:03:43 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Olivier Regnier <oregnier@steelbox.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: perl/script and retval
Message-ID:  <20070408125226.T73681@wonkity.com>
In-Reply-To: <46190C84.4080907@steelbox.org>
References:  <46190C84.4080907@steelbox.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070408125226.T73681>