in reply to Data::Dumper Dilema

If you check the documentation for Data::Dumper you will find that the Dumper function exported from the module does what you want.

The method-oriented call that you did expects to receive 2 arguments. The first will have all of your data, and the second says what your variables etc are named.

However beyond that I am finding it really hard to believe that the code you are showing is producing the output you describe. $sb is a thing. It is being expanded into a list. That cannot happen if $sb is a normal variable, in my version of Perl I cannot even get it to happen with a tie. I would need to look in the guts to see if you can do it with magic in XS.

If that actually is the code that produced that output, could you report back what the following code snipped produces, and the type of Perl you have?

use strict; use Data::Dumper; tie my $foo, 'Demo', qw(Testing one two three); print Dumper($foo); package Demo; sub TIESCALAR { my $class = shift; bless [@_], $class; } sub FETCH { my $self = shift; wantarray ? @$self : $self->[0]; }

Replies are listed 'Best First'.
Re: Re (tilly) 1: Data::Dumper Dilema
by vagnerr (Prior) on Feb 01, 2002 at 19:12 UTC
    I'll look into the Dumper function itself when I get the chance.

    The code realy does produce the output given. Talking to a college we came to the conclusion that the fact that $sb is actualy a class object rather than a simple data object might be causing confusion. Certainly Simon's solution does help convince it that it should be treating it as an array of arrays.

    I'll try the code you gave on the server in question tomorrow if I get time. Its a Linux box running perl 5.5 or 5.6 I dont remember the exact version.

    Thanks for your suggestions though.

    ---If it doesn't fit use a bigger hammer