Re: Checking the number of arguments passed to a Perl Program

2010-11-02 Thread David Christensen
Sri wrote: > Hi - I have just started with Perl and would need your help on this. > I am trying to write a program which expects two strings(arguments) > from the end user (no less, no more) and I would like to check if the > end-user did pass only two arguments. I am using the code below for > th

Re: Checking the number of arguments passed to a Perl Program

2010-11-02 Thread John W. Krahn
Sri wrote: Hi - I have just started with Perl and would need your help on this. Hello, I am trying to write a program which expects two strings(arguments) from the end user (no less, no more) and I would like to check if the end-user did pass only two arguments. @ARGV == 2 or die "usage: $0

Re: Checking the number of arguments passed to a Perl Program

2010-11-02 Thread David Christensen
Sri wrote: > Hi - I have just started with Perl and would need your help on this. > I am trying to write a program which expects two strings(arguments) > from the end user (no less, no more) and I would like to check if the > end-user did pass only two arguments. I am using the code below for > th

Re: Checking the number of arguments passed to a Perl Program

2010-11-02 Thread Shlomi Fish
Hi Sri, a few comments on your code. On Tuesday 02 November 2010 07:08:41 Sri wrote: > Hi - I have just started with Perl and would need your help on this. > > I am trying to write a program which expects two strings(arguments) > from the end user (no less, no more) and I would like to check if t

Re: Checking the number of arguments passed to a Perl Program

2010-11-01 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> couldn't you just do something like: sw> die "I said two variables\n" unless #$ARGV = 2; sw> ? that would be a good idea but you are off by one. you should rarely use $#foo as it gives the last index of an array. @foo in scalar context gives the size

Re: Checking the number of arguments passed to a Perl Program

2010-11-01 Thread shawn wilson
couldn't you just do something like: die "I said two variables\n" unless #$ARGV = 2; ? i'm not sure what you're asking? you already check this? On Tue, Nov 2, 2010 at 1:08 AM, Sri wrote: > Hi - I have just started with Perl and would need your help on this. > > I am trying to write a program whi