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!