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

Re: Testing for filehandles

Thread Previous | Thread Next
From:
eric-perl
Date:
March 27, 2002 15:52
Subject:
Re: Testing for filehandles
Message ID:
Pine.LNX.4.33.0203271431580.20427-100000@lucy
On Wed, 27 Mar 2002, Agustin Rivera wrote:
> Ok, I've tried it both ways and it returns 1 (true) as the value.  What am I
> doing wrong?

Agustin:

1. What *exactly* do you mean "both" ways?

2. References...

From the Getopt::Std man page:

getopt('oDI');		# -o, -D & -I take arg.  Sets opt_*...
getopts('oif:');	# -o & -i are boolean flags, -f takes an argument
			# Sets opt_*...

       Pass one argument which is a
       string containing all switches that take an argument.  For
       each switch found, sets $opt_x (where x is the switch
       name) to the value of the argument, or 1 if no argument.

From "The Ram Book":

  Getop::Std also provides the getopts function which lets you specify
  whether each option is Boolean or takes a value. Arguments that take a
  value... are indicated by a ':'

In summary: 

getopts() will set BOOLEAN values OR the value supplied *if* the option 
  is followed by a ':' in the function call getopts("x:").
getopt() will set the command-line value.

-- 
Eric P.
Los Gatos, CA


Thread Previous | 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