in reply to Re: my Scope Pop Quiz
in thread my Scope Pop Quiz

$rv is clearly undefined. An undefined value is represented by an empty string when printed (whether it is in an interpolated string or not).

#!/usr/bin/perl use strict; my $rv = 42 for (1); print "rv unquoted: '", $rv, "'\n"; print "rv quoted: '$rv'\n";

Replies are listed 'Best First'.
Re^3: my Scope Pop Quiz
by ikegami (Patriarch) on Apr 09, 2005 at 05:13 UTC
    An undefined value is represented by an empty string when printed

    yes, but an undefined value should also print a warning under -w when one attempts to print it, and I'm not getting any warnings when I specify -w. Very odd.

      $ perl -we 'use strict; my $rv = 42 for (1); print $rv,$/' Use of uninitialized value in print at -e line 1.
      Seems to be printing a warning for me. The original code didn't include "use warnings" in it, so I added some and the warning expected did appear.
        Not on my ActivePerl v5.6.1. Is that what you're using? I tried both use warnings; and -w, like I said in the first post. Very odd, eh?