lexical-underscore
view release on metacpan or search on metacpan
Bug tracker: <http://rt.cpan.org/Dist/Display.html?Queue=lexical-underscore>
Maintainer: Toby Inkster (TOBYINK) <tobyink@cpan.org>
0.004 2017-01-30
- Updated: Fix for Perl >= 5.24, where lexical $_ no longer exists.
0.003 2014-09-15
[ Bug Fixes ]
- Restore dynamic config which adds PadWalker to dependencies when Perl >=
5.9.0.
Fixes RT#98883.
Slaven ReziÄ++
<https://rt.cpan.org/Ticket/Display.html?id=98883>
0.002 2014-09-10
[ Packaging ]
- Switch to Dist::Inkt.
Makefile.PL view on Meta::CPAN
url => "git://github.com/tobyink/p5-lexical-underscore.git",
web => "https://github.com/tobyink/p5-lexical-underscore",
},
x_identifier => "http://purl.org/NET/cpan-uri/dist/lexical-underscore/project",
},
"version" => 0.004,
};
my %dynamic_config;
do {
$meta->{prereqs}{runtime}{requires}{'PadWalker'} = 0 if $] >= 5.009;
};
my %WriteMakefileArgs = (
ABSTRACT => $meta->{abstract},
AUTHOR => ($EUMM >= 6.5702 ? $meta->{author} : $meta->{author}[0]),
DISTNAME => $meta->{name},
VERSION => $meta->{version},
EXE_FILES => [ map $_->{file}, values %{ $meta->{x_provides_scripts} || {} } ],
NAME => do { my $n = $meta->{name}; $n =~ s/-/::/g; $n },
${lexical::underscore($level)}
If you happen to ask for $_ at a level where no lexical $_ is available,
you get the global $_ instead.
This module does work on Perl 5.8 but as there is no lexical $_, always
returns the global $_.
Technical Details
The `lexical::underscore` function returns a scalar reference to either a
lexical $_ variable somewhere up the call stack (using PadWalker magic),
or to the global $_ if there was no lexical version.
Wrapping `lexical::underscore` in `${ ... }` dereferences the scalar
reference, allowing you to access (and even assign to) it.
BUGS
Please report any bugs to
<http://rt.cpan.org/Dist/Display.html?Queue=lexical-underscore>.
SEE ALSO
PadWalker.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2012, 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the
same terms as the Perl 5 programming language system itself.
doap:file-release <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/lexical-underscore-0.002.tar.gz>;
doap:revision "0.002"^^xsd:string.
<http://purl.org/NET/cpan-uri/dist/lexical-underscore/v_0-003>
a doap:Version;
dc:identifier "lexical-underscore-0.003"^^xsd:string;
dc:issued "2014-09-15"^^xsd:date;
doap-changeset:changeset [
doap-changeset:item [
a doap-changeset:Bugfix, doap-changeset:Packaging;
rdfs:label "Restore dynamic config which adds PadWalker to dependencies when Perl >= 5.9.0.";
doap-changeset:fixes <http://purl.org/NET/cpan-uri/rt/ticket/98883>;
doap-changeset:thanks <http://purl.org/NET/cpan-uri/person/srezic>;
];
];
doap-changeset:released-by <http://purl.org/NET/cpan-uri/person/tobyink>;
doap:file-release <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/lexical-underscore-0.003.tar.gz>;
doap:revision "0.003"^^xsd:string.
<http://purl.org/NET/cpan-uri/dist/lexical-underscore/v_0-004>
a doap:Version;
lib/lexical/underscore.pm view on Meta::CPAN
use 5.008;
use strict;
use warnings;
BEGIN {
$lexical::underscore::AUTHORITY = 'cpan:TOBYINK';
$lexical::underscore::VERSION = '0.004';
}
use if ($] >= 5.009 && $] < 5.023), PadWalker => qw( peek_my );
BEGIN {
*peek_my = sub { +{} } unless __PACKAGE__->can('peek_my');
}
sub lexical::underscore
{
my $level = @_ ? shift : 0;
my $lexicals = peek_my($level + 2);
exists $lexicals->{'$_'} ? $lexicals->{'$_'} : \$_;
}
lib/lexical/underscore.pm view on Meta::CPAN
If you happen to ask for C<< $_ >> at a level where no lexical C<< $_ >> is
available, you get the global C<< $_ >> instead.
This module does work on Perl 5.8 but as there is no lexical C<< $_ >>, always
returns the global C<< $_ >>.
=head2 Technical Details
The C<lexical::underscore> function returns a scalar reference to either a
lexical C<< $_ >> variable somewhere up the call stack (using L<PadWalker>
magic), or to the global C<< $_ >> if there was no lexical version.
Wrapping C<lexical::underscore> in C<< ${ ... } >> dereferences the scalar
reference, allowing you to access (and even assign to) it.
=head1 BUGS
Please report any bugs to
L<http://rt.cpan.org/Dist/Display.html?Queue=lexical-underscore>.
=head1 SEE ALSO
L<PadWalker>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2012, 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
( run in 0.843 second using v1.01-cache-2.11-cpan-05444aca049 )