Re: How to make skip an input parameter.

2010-01-12 Thread Dr.Ruud
Parag Kalra wrote: use Getopt::Long; my ( $name, $passion, $age); my $result = GetOptions( 'name|n=s' => \$name, 'passion|p=s' => \$passion, 'age|a=i' => \$age, ); I prefer the hashref mode: #!/usr/bin/perl -wl use strict; use Data::Dump

Re: How to make skip an input parameter.

2010-01-11 Thread Steve Bertrand
Parag Kalra wrote: > use strict; > use warnings; The above should *always* be present in *every* Perl script, even when you think you are writing a script to test something only once. > use Getopt::Long; > > my ( $name, $passion, $age); > > my $result = GetOptions( >'name|n=s'

Re: How to make skip an input parameter.

2010-01-11 Thread Parag Kalra
Thank you folks. This is more than what I wanted. Here is my version of the same : ;) use strict; use warnings; use Getopt::Long; my ( $name, $passion, $age); my $result = GetOptions( 'name|n=s' => \$name, 'passion|p=s' => \$passion, 'age|a=i' => \$

Re: How to make skip an input parameter.

2010-01-11 Thread Steve Bertrand
Owen wrote: >> Hello All, >> >> This is surely a beginner's question and may even sound silly. :) >> >> How do you make a Perl script skip an input parameter if it is not >> present. >> Let me explain it through an example. >> >> EG: >> #!/usr/bin/perl >> use strict; >> use warnings; >> no warnings

Re: How to make skip an input parameter.

2010-01-09 Thread Jim Gibson
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 arg

Re: How to make skip an input parameter.

2010-01-09 Thread Owen
> Hello All, > > This is surely a beginner's question and may even sound silly. :) > > How do you make a Perl script skip an input parameter if it is not > present. > Let me explain it through an example. > > EG: > #!/usr/bin/perl > use strict; > use warnings; > no warnings 'uninitialized'; > prin

Re: How to make skip an input parameter.

2010-01-09 Thread Parag Kalra
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. Anyway thanks. :) Cheers, Parag On Sun, Jan 10, 2010 at 1:49 AM, Shlomi Fish wrote: > Hi Parag! > > On Satur

Re: How to make skip an input parameter.

2010-01-09 Thread Shlomi Fish
Hi Parag! On Saturday 09 Jan 2010 22:04:40 Parag Kalra wrote: > Or let me put it this way - How can we pass an input parameter as an undef > You can't put an undef in an @ARGV argument from the command line because all command-line arguments are strings. However, you can have it as an empty st

Re: How to make skip an input parameter.

2010-01-09 Thread Parag Kalra
Or let me put it this way - How can we pass an input parameter as an undef Cheers, Parag On Sun, Jan 10, 2010 at 1:23 AM, Parag Kalra wrote: > Hello All, > > This is surely a beginner's question and may even sound silly. :) > > How do you make a Perl script skip an input parameter if it is n

How to make skip an input parameter.

2010-01-09 Thread Parag Kalra
Hello All, This is surely a beginner's question and may even sound silly. :) How do you make a Perl script skip an input parameter if it is not present. Let me explain it through an example. EG: #!/usr/bin/perl use strict; use warnings; no warnings 'uninitialized'; print "1 - $ARGV[0]\n"; print