On Wed, 2002-03-27 at 18:46, [EMAIL PROTECTED] wrote:
> Hello, All:
>
> Is there a simple way to stop perl from complaining that a variable is
> only used once (possible typo at...)? e.g.,
>
> #! /usr/bin/perl -w
> use Getopts::Std;
>
> getopts('d');
>
> print "foo" if ($opt_d);
>
> If I use 'my()' perl complains that the variable is used in a void
> context. Since I'm testing for truth, I suppose that I could set $opt_d to
> zero before calling getopts('d')...
>
> --
> Eric P.
> Los Gatos, CA
rewrite the code snippet as
#! /usr/bin/perl -w
use vars '$opt_d'; #tell -w not to be concerned by $opt_d
use Getopts::Std;
getopts('d');
print "foo" if ($opt_d);
or better yet as
#! /usr/bin/perl -w
use vars '$opt_d'; #tell -w not to be concerned by $opt_d
use strict; #keep me from doing something stupid
use Getopts::Std;
getopts('d');
print "foo" if ($opt_d);
--
Today is Boomtime the 14th day of Discord in the YOLD 3168
Keep the Lasagna flying!
Missile Address: 33:48:3.521N 84:23:34.786W
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]