How to check if LVALUE represents SCALAR

For years, I am using a code that contains the following condition ref \$_[0] eq ‘SCALAR’ I always expect there an ARRAY or SCALAR, but recently I passed substr() into that parameter. Unexpected things happened. The condition returned a false value. Then I figured it out. The ref returned LVALUE instead of SCALAR. Since LVALUE… Read More How to check if LVALUE represents SCALAR

Perl print "$("

I’m just starting to learn Perl, and I (accidentally) came across this print behavior I can’t explain. If I do: print "$("; the result I get is: 1000 4 20 24 25 27 29 30 44 46 117 1000 1001 Here’s a nice screenshot. Probably makes total sense for someone who knows Perl, so if… Read More Perl print "$("

sort function in Perl – random output

I’m trying to write a sort function in Perl. I need that "name_iwant_last" will be the last in sorted hash. My code: %libs = ( "00000000000","00000000000", "aaaaaaaaaaa","aaaaaaaaaaa", "AAAAAAAAAA","AAAAAAAAAA", "name_iwant_last","name_iwant_last", "zzzzzzzzzzzzz","zzzzzzzzzzzzz", "ZZZZZZZZZZZ","ZZZZZZZZZZZ", "9999999999","9999999999" ); sub lib_sort { #print "cosa ordino "; #print $libs{$a}; #print $libs{$b}; #print "\n"; return 1 if (index($libs{$a} , "name_iwant_last") != -1); return… Read More sort function in Perl – random output