> 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 "2 - $ARGV[1]\n";
> print "3 - $ARGV[2]\n";
>
> When I execute this as - perl Input.pl one two three
>
> I get following O/P
>
> 1 - one
> 2 - two
> 3 - three
>
> Now suppose I don't want to give second parameter - perl Input.pl one
> three
>
> I get following O/P:
>
> 1 - one
> 2 - three
> 3 -
>
> My requirement is -
>
> 1 - one
> 2 -
> 3 - three
>
> I tried giving extra white space but still 'three' is being taken as
> 2nd
> input parameter and I guess white space is a default delimiter. Is
> there any
> special delimiter which I can use to skip an I/P parameter.





I know what you are asking, and I have seen the answer by Shlomi Fish
but wonder if using Getopt::Std would not be another avenue to
explore.

Or for that matter, Getopt::Long

-- 



Owen


-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to