Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Strange name

by esharris (Monk)
on May 29, 2003 at 16:50 UTC ( [id://261608]=perlquestion: print w/replies, xml ) Need Help??

esharris has asked for the wisdom of the Perl Monks concerning the following question:

Why does the execution of the following program output "TRUE"? I expected an error indicating that TRUE was undefined.
#!/usr/local/bin/perl -w use strict; print TRUE."\n";

edited: Thu May 29 20:51:55 2003 by jeffa - code tags

Replies are listed 'Best First'.
Re: Strange name
by broquaint (Abbot) on May 29, 2003 at 16:58 UTC
    Since all barewords in perl are essentially strings, and you're forcing stringification with the concatenation, this behaviour is to be expected e.g
    shell> perl -MO=Deparse -Mstrict -Mwarnings -e 'print TRUE."\n";' print 'TRUE' . "\n"; -e syntax OK

    HTH

    _________
    broquaint

Re: Strange name
by boo_radley (Parson) on May 29, 2003 at 17:11 UTC
    perl (and strict) doesn't recognize TRUE as a variable (it has no sigil), but as a literal, which perl recognizes as plain text.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://261608]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found