dump perl lexical variables

problem defined:
– Many financial perl systems “use strict”. Programmers typically use lexicals (ie “my $var;”), although “our” is sometimes good enough. By the way, “our” can introduce side effects, compromise isolation and modularization…
– Some lexicals are complex and need a deep dumper
– The extremely /handy/ sss() subroutine can’t see lexicals, although it can see locals ie dynamically scoped
– Perl restriction: P264: Lexicals are invisible by symbolic ref. Try eval
– perl restriction: lexicals are invisible, by any means, outside the lexcical scope. I think we have to keep sss() in the same source file.

Suggestion: use Data::Dumper. I think this can’t see lexicals. Try Dumper(\$your_lex);
Suggestion: our $var99 = $var; sss(‘var’); # inside sss(), we check both var99 and var
Suggestion: P743 of the camel says “unless … the subroutine itself is textually enclosed within the scope ….”. Also P222. Well, if a lexical is declared in a nested block, move sss() definition in?

Suggestion: (cheat) change my to local or our

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s