Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Scoping Variables

by Clachair (Acolyte)
on May 18, 2001 at 07:28 UTC ( [id://81424]=note: print w/replies, xml ) Need Help??


in reply to Re: Scoping Variables
in thread Scoping Variables

Ahem, er, am I missing something really simple here?
I wouldn't expect this statement to work:-
if ($foo) { print "the date is... $date \n <br>"; }
at least not on my Perl version.

Surely, it should be:-
if ($foo) { print "The date is...", $date, "\n <br>"; }


Never lick a gift horse in the mouth.

Replies are listed 'Best First'.
Re: Re: Re: Scoping Variables
by Anonymous Monk on May 18, 2001 at 18:13 UTC
    Yes, you are missing something really simple here. It's called interpolation and it happens inside double quotes. Put this in a script and run it. $x=1; print 'single quoted dollar x is $x'; print "\n"; print "double quoted dollar x is $x"; print "\n"; perl -e '
      WHOOPS, Sorry. That should have been
      $x=1; print 'single quoted dollar x is $x'; print "\n"; print "double quoted dollar x is $x"; print "\n";
      Many thanks.
      Neither of my enormous tomes containing Perls of wisdom explained that one!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-16 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found