(@ARGV # if @ARGV has elements && # and $ARGV[0] eq '-v' # The first element of @ARGV is '-v' && # and shift); # remove the first element from @ARGV
In Perl, && is a shortcutting operator. That is, in A && B, perl will only evaluate B if A is true. The first && in your code is a traditional logical AND but the second makes sure that shift is only executed if the first && is true (ie when @ARGV isn't empty and it's first element is '-v').
The logical result is then asssigned to $verbose: true IFF $ARGV[0] eq "-v" and has the side-effect of shifting @ARGV if it was.
In reply to Re: ARGV question
by FunkyMonk
in thread ARGV question
by Johnny Utah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |