SPUG: Data::Dumper mania - Stop the Madness!

Tim Maher/CONSULTIX tim at consultix-inc.com
Thu Jan 27 01:37:08 CST 2000


Jeremy (and countless others),

Thanks for your analysis - I'm just working through Conway's impressive
OO Perl book today, and still a bit confused about the syntax elements
and their associated behaviors, while experiencing significant crosstalk
from ancient C++ memories.  The reply-postings elicited by my deranged
attempts to explain and understand my own program turned out to be very
educational to me!

But I'm not, as you intimate, "hell bent on breaking the API" ! 8-} 

I was just following the lead of "Effective Perl Programming" (p. 148)
and "Advanced Perl Programming" (p. 158), which both show uses of
Data::Dumper->Dump like mine.  It struck me as odd that Dump wasn't
automatically imported into my namespace, so I was exploring the idea
of making an alias for it. (Still haven't found one that works,
but surprisingly I find that I no longer care  . . . 8-})

Sorry about adding to the confusion by claiming my invocation was
Data::Dumper::Dump(), when in fact, by version 42 when the program
actually worked, it had become Data::Dumper->Dump()! 8-}

Thanks to all for their input, and  Goodnight! 9-|

-Tim

*========================================================================*
| Tim Maher, PhD  Consultix &              (206) 781-UNIX/8649           |
|  Pacific Software Gurus, Inc             Email: tim at consultix-inc.com  |
|  UNIX/Linux & Perl Training              http://www.consultix-inc.com  |
| 2/22: UNIX  2/28: Perl Modules  2/29: Int. Perl  3/3: Pattern Matching |
*========================================================================*


On Wed, Jan 26, 2000 at 11:10:26PM -0800, Jeremy Devenport wrote:
> Here's my quick analysis, you can repost any interesting bits to the
> list if you like and it's not too redundant.
> 
> Effective Perl Programming, page 148:
> 
>  use Data::Dumper;
>  $a = { H => 1, He => 2, Li => 3, Be => 4 };
>  $b = { B => 5, C => 6, N => 7, O => 8 };
>  print Data::Dumper->Dump([$a, $b], [qw(a b)]);
> 
> Data/Dumper.pm
>     153  zub Dump {
>     154    my($s) = shift;
>  ...159    $s = $s->new(@_) unless ref $s;
> 
> The EPP example isn't calling Dump as a zubroutine it is calling it as a
> class method, so the name of the class is passed automagically as the
> first argument.
> 
> If Dump had been called like $my_dump_object->Dump then perl would have
> automagically passed the blessed reference representing the object as
> the first argument. Line 159 of the Dump method checks to see if it was
> called on an existing object or as a class method generating a new
> object. 
> 
> If you're really hell bent on breaking the API try passing undef or any
> other non-ref thing as the first argument explicitly when you call it as
> a zubroutine.
> 
> Jeremy

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list