At 2:09 AM +0530 1/10/10, Parag Kalra wrote:
Hmmm.
Although its sufficing my needs but I wanted a way to pass an undef. May be
I will have make it undef manually if an input parameter is an empty string
or something like that.
The "normal" way to set a variable as undef using command-line
arguments is to declare it as undef and only assign a value if
something is entered on the command-line. The usual way to enter
command-line values is to use the '-x' convention whereby a unique
dash-letter or dash-string combination is entered, parsed by your
program, and used to set a variable.
See the documentation for the Getopt::Long module, probably the most
common module used to parse command-line arguments.
For example, to set the value of $someval to undef in a program using
Getopt::Long, do something like the following:
use Getopt::Long;
my $someval;
GetOptions( 'x' => \$someval );
At this point, $someval will be 1 if '-x' was entered and undef if it was not.
See 'perldoc Gepopt::Long' for the many possibilities.
--
Jim Gibson
[email protected]
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/