in reply to Re: Re: Checking for data entry
in thread Checking for data entry

Shift just gets you the first element of the array and removes it from the array so a subsequent shift will get the next element and so on. With no array specified it uses @ARGV (or @_ in a subroutine), so the versions you give are equivalent in this case, each checking just one argument.

Similar but NOT equivalent would be:

my $StartDir = $ARGV[0] || die "Usage: $0 <startdir>\n";
That checks the first command line argument but does not remove it from the argument list.

--
I'd like to be able to assign to an luser

Replies are listed 'Best First'.
Re: Re: Re: Re: Checking for data entry
by Anonymous Monk on Jul 08, 2003 at 16:00 UTC
    thanks for the info. So this doesnt have a bug?
    my $StartDir = shift || die "Usage: $0 <startdir>\n";
      Well it will do what you want and I use it all the time for my little scripts, but it is not particluarly maintenance friendly. What if someone inserts another shift before yours for example? How robust you want your code to be will determine how you code this (and everything else too really).

      --
      I'd like to be able to assign to an luser

        Thanks for all your help on this! I learned alot from your examples.