Re: Dumping values of all vars

2004-01-15 Thread Dan Anderson
On Thu, 2004-01-15 at 18:17, James Edward Gray II wrote:
> On Jan 15, 2004, at 5:06 PM, Dan Anderson wrote:
> 
> > And I agree that Data::Dumper is much more complicated then it needs to
> > be.
> 
> Data::Dumper is a standard module and I find it super useful.  I just 
> showed it in a one liner, so I don't think we can say it's too hard to 
> get into.  I encourage others to check it out for themselves.

Well yes it is useful.  Perhaps I should have said that I /prefer/
Data::Dump because that's the Perl module I originally found to do
dumping.  

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-15 Thread James Edward Gray II
On Jan 15, 2004, at 5:06 PM, Dan Anderson wrote:

And I agree that Data::Dumper is much more complicated then it needs to
be.
Data::Dumper is a standard module and I find it super useful.  I just 
showed it in a one liner, so I don't think we can say it's too hard to 
get into.  I encourage others to check it out for themselves.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Dumping values of all vars

2004-01-15 Thread Dan Anderson
> As a rule though, Data::Dumper doesn't erase data, as you can see below:

One more thing.  I have noticed a problem with Data::Dump where if the
data structures are too complex the data can disapear.  I'm not quite
sure why.  Usually I use it in {}s on a temporary variable which is a
copy of what I'm dumping

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-15 Thread Dan Anderson
On Thu, 2004-01-15 at 17:59, James Edward Gray II wrote:
> On Jan 15, 2004, at 4:40 PM, Dan Anderson wrote:
> 
> > I use the Data::Dump package which is a standard module.
> 
> I'm willing to bet you actually use Data::Dumper.

Oh yeah, how much are we betting?  My car could use turbo chargers and
NOS.  :-D

>From the POD:

The Data::Dump module grew out of frustration with Sarathy's
in-most-cases-excellent Data::Dumper. Basic ideas and some code are
shared with Sarathy's module.

The Data::Dump module provides a much simpler interface than
Data::Dumper. No OO interface is available and there are no
configuration options to worry about (yet :-). The other benefit is that
the dump produced does not try to set any variables. It only returns
what is needed to produce a copy of the arguments. This means that
dump("foo") simply returns "foo", and dump(1..5) simply returns (1, 2,
3, 4, 5).


And I agree that Data::Dumper is much more complicated then it needs to
be.

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-15 Thread Dan Anderson
On Thu, 2004-01-15 at 17:59, James Edward Gray II wrote:
> On Jan 15, 2004, at 4:40 PM, Dan Anderson wrote:
> 
> > I use the Data::Dump package which is a standard module.
> 
> I'm willing to bet you actually use Data::Dumper.

Nope.  I use Data::Dump.  Then I call Data::Dump::dump() to dump a
variable.

http://search.cpan.org/~gaas/Data-Dump-1.02/lib/Data/Dump.pm

I was, however, mistaken that it's part of the default Perl install when
you build it from source (although it is part of the default install on
Mandrake Linux).

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-15 Thread James Edward Gray II
On Jan 15, 2004, at 4:40 PM, Dan Anderson wrote:

I use the Data::Dump package which is a standard module.
I'm willing to bet you actually use Data::Dumper.

Be warned that calling Data::Dump::dump($variable) will undef 
$variable!
Well, Dump() (not dump) is meant to be called as a method and takes 
references to variables, so there is quite a bit wrong with the above 
line which could explain your troubles.

As a rule though, Data::Dumper doesn't erase data, as you can see below:

perl -MData::Dumper -e '$var = 103; print Dumper(\$var); print "Still 
holds:  $var.\n"'
$VAR1 = \103;
Still holds:  103.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Dumping values of all vars

2004-01-15 Thread Dan Anderson
On Thu, 2004-01-15 at 12:35, zentara wrote:
> On Wed, 14 Jan 2004 12:40:31 -0700, [EMAIL PROTECTED] (Jdavis) wrote:
> 
> >Hello,
> > Is it possible to dump the values of all the vars in a perl script
> >easily? I want to have a sub called Error that when called 
> >will tell me the current value of all the vars in the script.
> >
> >thanks,
I use the Data::Dump package which is a standard module.  Be warned that
calling Data::Dump::dump($variable) will undef $variable!

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-15 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jdavis) writes:
>Hello,
> Is it possible to dump the values of all the vars in a perl script
>easily? I want to have a sub called Error that when called 
>will tell me the current value of all the vars in the script.

You can dump out all the variables in package foo by inspecting the
hash %foo:: .  The library dumpvar.pl in the perl distribution may
help here.

For lexical variables, you probably want PadWalker; see:
http://search.cpan.org/~robin/PadWalker-0.10/PadWalker.pm .

Of course, the debugger provides a nice interactive way of doing this.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dumping values of all vars

2004-01-14 Thread Mark Stosberg
On 2004-01-14, jdavis <[EMAIL PROTECTED]> wrote:
> Hello,
>  Is it possible to dump the values of all the vars in a perl script
> easily? I want to have a sub called Error that when called 
> will tell me the current value of all the vars in the script.

Have you read about the perl debugger? I recommend "perldoc perldebtut".
It has a function to dump all the values in the current name space.
That doesn't directly answer your question, but it may help with your
issue.

Mark

-- 
http://mark.stosberg.com/ 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Dumping values of all vars

2004-01-14 Thread jdavis
Hello,
 Is it possible to dump the values of all the vars in a perl script
easily? I want to have a sub called Error that when called 
will tell me the current value of all the vars in the script.

thanks,
-- 
jdavis <[EMAIL PROTECTED]>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]