5. More about || and &&
||
and &&
return the last argument that was evaluated. Thus, ||
is useful for assigning default values, like this:
#!/usr/bin/env perl use strict; use warnings; # shift by default shifts from @ARGV in the main program my $start = shift || 1; my $end = shift || ($start+9); for my $i ($start .. $end) { print "$i\n"; }