develooper Front page | perl.beginners | Postings from March 2002

Quieting 'Name "main::foo" only used once..."

Thread Next
From:
eric-perl
Date:
March 27, 2002 16:51
Subject:
Quieting 'Name "main::foo" only used once..."
Message ID:
Pine.LNX.4.33.0203271540280.20427-100000@lucy
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


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About