in reply to Re^4: Arrgh, can() appears to work for non-object !!
in thread Arrgh, can() appears to work for non-object !!
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:
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.$ 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. $
|
|---|