Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   my $variables (http://www.velocityreviews.com/forums/t946623-my-variables.html)

George Mpouras 05-31-2012 07:54 AM

my $variables
 
is there any way to catch the "my" variable names like the "our" variables ?

my $var_001 = 'hello';
our $var_002 = 'world';
foreach (grep /var/, keys %{__PACKAGE__.::}) {print "$_
",${__PACKAGE__.::}{$_},"\n"}



Peter Makholm 05-31-2012 08:10 AM

Re: my $variables
 
"George Mpouras" <nospam.gravitalsun@hotmail.com.nospam> writes:

> is there any way to catch the "my" variable names like the "our" variables ?


Yes, with the peek_my function from PadWalker.

PadWalker has some interesting use cases, but if you need it in you
daily development then you are either hacking perl internals or doing
something wrong.

//Makholm


George Mpouras 05-31-2012 11:21 AM

Re: my $variables
 
PadWalker does not help, you have to know the variable name. I want all the
my ... to decide what to do after I know their names. There is product that
inside their C code they have warp Perl



Peter Makholm 05-31-2012 12:11 PM

Re: my $variables
 
"George Mpouras" <nospam.gravitalsun@hotmail.com.nospam> writes:

> PadWalker does not help, you have to know the variable name. I want all the
> my ... to decide what to do after I know their names.


I have no idea what you are looking for if it isn't just

keys %{ my_peek(0) };

//Makholm


All times are GMT. The time now is 08:31 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.