Does that mean that it's safe to infer that perl will, if it thinks it appropriate, treat all literals/string constants as class names ?
No. It will only treat strings that start with a letter or underscore to be class names:
$ perl -wE 'say "fred" -> can ("can")'
Use of uninitialized value in say at -e line 1.
$ perl -wE 'say "1fred" -> can ("can")'
Can't call method "can" without a package or object reference at -e li
+ne 1.
$ perl -wE 'say " " -> can ("can")'
Can't call method "can" without a package or object reference at -e li
+ne 1.
$ perl -wE 'say "f r e d" -> can ("can")'
Use of uninitialized value in say at -e line 1.
$
But this "autocasting" is not surprising. Perl does that all the time. String can be numbers or regexes. Numbers can be strings. Floats can be integers, etc. |