Subject: | Data::Dump issue, I think |
Date: | Thu, 13 Aug 2009 16:11:36 +0200 |
To: | Gisle Aas <gisle [...] aas.no>, bug-Data-Dump [...] rt.cpan.org |
From: | Aaron Naiman <naiman [...] math.jct.ac.il> |
Dear Gisle,
Hi there. Great modules you have written -- thanx!
I have sat on a problem for a number of hours, scratching my head (<OUCH>!)
and peeling the code down to something as small as possible.
I have the behavior in my normal scripts, but here are the lines for copying
into: perl -d -w -e 42
use URI
use Data::Dump qw(pp)
$url = [ bless(do{\(my $o = "http://google.com")}, "URI::http"), ]
$data_string = pp(@{$url})
@copy_of_url = eval($data_string)
$copy_of_url = \@copy_of_url
p ${$copy_of_url}[0]
With this, the output is:
URI::http=SCALAR(0x9eb79ac)
which is *not* what I wanted.
However, if before the definition of $url I have the following line:
$dummy = new URI('http://redhat.com')
then the output is:
http://google.com
as expected.
*Why* does this $dummy definition make the operator overloading work (and
the URI object acts as if it invokes as_string)??
Please note that if the $dummy definition did not have an argument to the
constructor, it would *not* have worked! (??)
Finally, if I scale back $url to be an object (from the "bless ..." on), and
not an array of such, then there is no problem, and the $dummy definition is
not needed at all.
This is very curious behavior, and I hope I am not wasting your time with my
lack of object expertise.
Thanx so my for your time!
BFN,
Aaron
--
Aaron ("Aharon") Naiman
Jerusalem College of Technology--Machon Lev
naiman@math.jct.ac.il
http://math.jct.ac.il/~naiman