in reply to Re^4: doubts about Data::Dumper output
in thread doubts about Data::Dumper output

Not that weird, it returns a lexical scalar variable for the slot.

But without polluting the namespace with the dummy name $o, cause the scope is limited.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Replies are listed 'Best First'.
Re^6: doubts about Data::Dumper output
by Anonymous Monk on Oct 07, 2014 at 08:35 UTC

    Not that weird, it returns a lexical scalar variable for the slot. But without polluting the namespace with the dummy name $o, cause the scope is limited.

    Sure its weird to write  do { my $o} when it could write undef or "DUMMY" or "fix" or "V: $VAR1->{a}" or any other string

      > when it could write ... "V: $VAR1->{a}"

      MidLifeXis already explained purity

      > when it could write undef or "DUMMY" or "fix"

      see Scalar::Util readonly to understand the difference between passed literals and variables.

      readonly SCALAR Returns true if SCALAR is readonly. sub foo { readonly($_[0]) } $readonly = foo($bar); # false $readonly = foo(0); # true

      If you think Data::Dumper should be cleverer instead of playing safe, you are free to provide a patch.

      > Sure its weird

      Claiming a "bug" without deeper knowledge seems weird to me.

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

        Hmm, I made a mistake about a bug, I thought Deparse was turned on but it wasn't deparsing it was only showing do { my $o} so thats the bug I was talking about, and I was wrong about that because Deparse wasn't turned on

        So I was wrong about the bug, do { my $o} is still weird as a placeholder, so I called it weird, it is weird

        All that other stuff doesn't make do { my $o} any less weird as a placeholder when undef will work (its undef), its a placeholder, its gets replaced

        LanX too much pendantic