in reply to Printing an element of a list not an array

It seems no one has mentioned another common way of avoiding this trap:
perl -E 'say +(localtime)[1]'

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Printing an element of a list not an array
by Marshall (Canon) on Aug 25, 2016 at 22:44 UTC
    I was surprised that this worked, but it did:
    my @array = (32, "something","something01","01something"); print scalar @array."\n"; #prints 4 print +(@array)[0], "\n"; #prints 32 print +(@array)[1], "\n"; #prints something print +(@array)[2], "\n"; #prints something01 print +(@array)[3], "\n"; #prints 01something
    An issue that I see is how Perl handles math on strings and potential confusion resulting from that:
    my $test = '01xxx'; $test += 1; print "01xxx + 1 is: $test\n"; #prints 2
    I do most of my work on Windows now and printing to the console in any form is such an incredibly "expensive" execution wise operation that I prefer the print "".function; option. The string concatenation is meaningless in the overall scheme of things.
Re^2: Printing an element of a list not an array
by stevieb (Canon) on Aug 25, 2016 at 23:12 UTC
    I was going to mention that, but had forgotten by the time I had completed my post. I'm glad you've added it to the thread. Cheers, choroba!