lexicalsGet a hash of your current 'my' variables | |
Download |
lexicals Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Publisher Name:
- Ingy d%uFFFDt Net
- Publisher web site:
- http://search.cpan.org/~ingy/
lexicals Tags
lexicals Description
Get a hash of your current 'my' variables Python has a builtin function called `locals()` that returns the lexically scoped variables in a name/value mapping. This is a very useful idiom. Instead of needing to create a hash like this: my $hash = { foo => $foo, bar => $bar, };Just say: my $hash = lexicals;Assuming you have a $foo and $bar defined, you get the same thing.lexicals is a Perl module that exports a function called `lexicals`. This function returns the lexicals as a hash reference (in scalar or list context).SYNOPSIS use Template::Toolkit::Simple; use lexicals; sub mail { my $self = shift; my $name = 'Mr. ' . $self->get_name; my $address = $self->fetch_address($name); my $stamp = Postage::Stamp->new(0.44); my $envelope = tt->render('envelope', lexicals); } Requirements: · Perl
lexicals Related Software