I’ve been delving into the Perl language more lately for a job, and have found out some interesting things about it. Perl itself is a bit shrouded in mysticism, with it often being said that it runs on “magic”. The original Perl engine, written by Larry Wall, has never been duplicated due to its incredible complexity and hacked together nature.
but you can actually declare the exact same array and hash objects like this
@MyArray=('a',1,'b',2); #An array with values a,1,b,2
%MyHash=(a=>1, b=>2); #A hash with keys a,b that contain the values 1,2
@MyArray=('a'=>1=>'b'=>2); #An array with values a,1,b,2
%MyHash=(a,1,b,2); #A hash with keys a,b that contain the values 1,2
or
print $#MyArray; #Index of the last element, so add 1 to get length
$ArrayLength=@MyArray;
print $ArrayLength;
Moral of the story: there are many ways to do things in Perl.
$MyRefArray=[1,2,3];
print scalar @$MyRefArray;
print $#$MyRefArray; #Index of the last element, so add 1 to get length
After now having delved a bit more into how Perl works, I still like PHP better as a strictly quick scripting language. Oh well.