st-dump.pl revision 1
1N/A# Copyright (c) 1995-2000, Raphael Manfredi 1N/A# You may redistribute only under the same terms as Perl 5, as specified 1N/A# in the README file that comes with the distribution. 1N/A print $
ok ?
"ok $num\n" :
"not ok $num\n";
1N/A print "# Expected $right\n";
1N/A print "# Got undef\n";
1N/A print "# Got $left\n";
1N/A $
left =~ s/([^-a-
zA-
Z0-
9_+])/
sprintf "\\%03o",
ord $
1/
ge;
1N/A print "# Got \"$left\"\n";
1N/A 'SCALAR' =>
'dump_scalar',
1N/A 'LVALUE' =>
'dump_scalar',
1N/A 'ARRAY' =>
'dump_array',
1N/A 'HASH' =>
'dump_hash',
1N/A 'REF' =>
'dump_ref',
1N/A# Given an object, dump its transitive data closure 1N/A croak "Not a reference!" unless ref($
object);
1N/A# This is the root recursive dumping routine that may indirectly be 1N/A# called by one of the routine it calls... 1N/A# The link parameter is set to false when the reference passed to 1N/A# the routine is an internal temporay variable, implying the object's 1N/A# address is not to be dumped in the %dumped table since it's not a 1N/A# user-visible object. 1N/A # Get something like SCALAR(0x...) or TYPE=SCALAR(0x...). 1N/A # Then extract the bless, ref and address parts of that string. 1N/A # Special case for references to references. When stringified, 1N/A # they appear as being scalars. However, ref() correctly pinpoints 1N/A # them as being references indirections. And that's it. 1N/A # Make sure the object has not been already dumped before. 1N/A # We don't want to duplicate data. Retrieval will know how to 1N/A # relink from the previously seen object. 1N/A # Call the appropriate dumping routine based on the reference type. 1N/A # If the referenced was blessed, we bless it once the object is dumped. 1N/A # The retrieval code will perform the same on the last object retrieved. 1N/A croak "Unknown simple type '$ref'" unless defined $
dump{$
ref};
1N/A# Indicate that current object is blessed 1N/A# Dump reference to reference