in reply to Re: Perl Array - What an array contains
in thread Perl Array - What an array contains
Watch out, though. $#capitals would evaluate to true (-1) if the list has no capitals:
perl -lE "@capitals=(); $,=', '; print scalar(@capitals), $#capitals, +$#capitals ? 'Lots' : 'One'; 0, -1, Lots perl -lE "@capitals=qw(London); $,=', '; print scalar(@capitals), $#ca +pitals, $#capitals ? 'Lots' : 'One'; 1, 0, One perl -lE "@capitals=qw(London Paris); $,=', '; print scalar(@capitals) +, $#capitals, $#capitals ? 'Lots' : 'One'; 2, 1, Lots
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl Array - What an array contains
by AnomalousMonk (Archbishop) on Aug 28, 2016 at 21:40 UTC | |
|
Re^3: Perl Array - What an array contains
by hippo (Archbishop) on Aug 25, 2016 at 13:27 UTC |