in reply to Search for a character in CAPS
A word that has no other interpretation in the grammar will be treated as if it were a quoted string. These are known as ``barewords''. As with filehandles and labels, a bareword that consists entirely of lowercase letters risks conflict with future reserved words, and if you use the -w switch, Perl will warn you about any such words. Some people may wish to outlaw barewords entirely.There's more in perldata about the much (and generally rightly) maligned bareword.
If this still doesn't make sense, compare the 2 short programs :
This will not run because PerlBeginner is not a core perl routine, and not a sub defined in the script, or in the strict or diagnostics modules.use strict; use diagnostics; my $foo=PerlBeginner; print $foo;
Compare that with :
Now replace "PerlBeginner" with "Perl Beginner", and see what happens. This compiles and runs because the string is wrapped in quotes. Also note the use strict and use diagnostics pragmas. These will alert you to the use of barewords (and other things) and enable verbose error messages for debugging, respectively. Most people consider the use of strict to be mandatory for scripts of any complexity.use strict; use diagnostics; my $foo="PerlBeginner"; print $foo;
If you don't like the idea of having to use quotes, look in perlop under "Quote and Quote-like Operators" for other ways to do it.
update : If this doesn't help you, or was way off base, please consider adding a little more descriptive content to your question; the three responses you've gotten so far are all over the field.
|
|---|