CPU: Perl, Fall 2005 Perl, Week 2: Arrays, Hashes, Control Structures #30

More Index Tricks

$sides[0] = 'sweet potatoes';
$sides[1] = 'mac & cheese';
$sides[2] = 'apples';
print $sides[ -1 ];
$sides[-4] = 'this will asplode';
print $#sides, "\n"; # prints 2
Copyright © 2005 Ian Langworth