Gossamer Forum
Home : General : Perl Programming :

Show all variables made/sent from a Perl script?

Quote Reply
Show all variables made/sent from a Perl script?
I'm trying to add some debugging stuff in one of my scripts. Is there anything that will display ALL of the variables in a Perl script, i.e any variable that is available in that part of the script? I've had a look on Google, but I'm not quite sure what I'm looking for Unimpressed

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
I'm not really sure that you mean?
Quote Reply
Re: [Paul] Show all variables made/sent from a Perl script? In reply to
i.e. if I set a vaiable in a script, like;

Code:
#!/usr/bin/perl

$var1 = "tedst";
$something = "another test";

Then, I want something that will display all the available variables. So it would print something like;

var1 => tesdst
something => another test

Basically, something like a 'for' used to display the contents of $IN->param.

Does that make more sense?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
Sometimes I astound myself Wink

http://213.106.15.160/cgi-bin/test.cgi
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
Hi Andy,

I think you're going to need some sort of IDE debugger to show all vars. I know Komodo from ActiveState has a debugger that will do what you want: http://www.activestate.com/Products/Komodo/.

You can also do something like what GT does in their env subs to print the values of specific global vars when a program dies. This is mainly for globals as most other vars have most likely gone out of scope at this point.

The other option is to print the values you need to the error log as you go.

Regards,
Charlie

[edit]Or what Paul did :)[/edit]

Last edited by:

Chaz: Mar 22, 2003, 7:36 AM
Quote Reply
Re: [Paul] Show all variables made/sent from a Perl script? In reply to
Wow....how did you do that Paul? Thats exactly what I'm looking for....Cool

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
I'm not sure its "exactly" what you want. It seems that only globally scoped variables will be listed. When I try dclaring with my() they don't appear.....that shouldn't be an issue with your code though right Wink

I just need to fix a few things then I'll post the code.
Quote Reply
Re: [Chaz] Show all variables made/sent from a Perl script? In reply to
I've never tried Komodo before....just downloaded it. It is pretty cool actually. I just used pod2html on GT::Template...makes a really nice job ;)

Last edited by:

Paul: Mar 22, 2003, 8:28 AM
Quote Reply
Re: [Paul] Show all variables made/sent from a Perl script? In reply to
I thought that was pretty cool too. I also like the regex tool kit it has. It's great when your regexes don't do what you think they're supposed to do :) I flipflop between Komodo, HomeSite and gvim, I can't seem to stick with just one.
Quote Reply
Re: [Chaz] Show all variables made/sent from a Perl script? In reply to
Mmm..what has a regex tool in it? In case you havn't noticed, my regex skills are crap Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
This is a basic example and was thrown together using snippets I found on the net.
Quote Reply
Re: [Andy] Show all variables made/sent from a Perl script? In reply to
Komodo has a built-in "Regular Expression (Rx) Toolkit". More details here: http://www.activestate.com/...ore_information.plex I think they have a screenshot of it on that page as well.

~Charlie
Quote Reply
Re: [Chaz] Show all variables made/sent from a Perl script? In reply to
Ooo I really like that regex toolkit!

Here's a little regex for a url =)

Code:
([^:]+)://(?:([a-z0-9.-]+)\.)?([a-z0-9-]+)\.([a-z0-9\.]+)/

Last edited by:

Paul: Mar 22, 2003, 9:45 AM