summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2022-10-31 21:20:08 +0000
committerYves Orton <demerphq@gmail.com>2023-02-22 12:58:26 +0100
commitb625025e93c87eab6565ea086e7d9c60245d6bd3 (patch)
treefa4bdcaa58cd273f4a8339532387656a42725872 /dist
parentc19e3e4e83b25cf2c13581094e9c56bca2f44e1e (diff)
downloadperl-b625025e93c87eab6565ea086e7d9c60245d6bd3.tar.gz
Prefer scalar assignment to get caller's first return value
Multiple forms of syntax can be used to obtain a package name from `caller`, which emits this as its first return value, and assign that name to a lexical scalar. The following each achieve the same result, but with varying efficiency: * `sub callme { my $package = caller(2); ...}` * `sub callme { my ($package) = caller(2); ...}` * `sub callme { my $package = (caller(2))[0]; ...}` In the first example, `pp_caller` determines only the package name and pushes it to the stack. In the other two examples, the other 10 of `caller`'s return values are calculated and pushed onto the stack, before being discarded. This commit changes non-CPAN-first instances of the latter two forms in core to the first form. Note: There is a special exception to the equivalence described above, when caller is use in list context within the DB package. Such a usage instance in regen/warnings.pl therefore remains unchanged.
Diffstat (limited to 'dist')
-rw-r--r--dist/Env/lib/Env.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/dist/Env/lib/Env.pm b/dist/Env/lib/Env.pm
index eaf30f15a3..991afddc02 100644
--- a/dist/Env/lib/Env.pm
+++ b/dist/Env/lib/Env.pm
@@ -1,6 +1,6 @@
package Env;
-our $VERSION = '1.05';
+our $VERSION = '1.06';
=head1 NAME
@@ -75,7 +75,7 @@ Gregor N. Purdy E<lt>F<gregor@focusresearch.com>E<gt>
=cut
sub import {
- my ($callpack) = caller(0);
+ my $callpack = caller(0);
my $pack = shift;
my @vars = grep /^[\$\@]?[A-Za-z_]\w*$/, (@_ ? @_ : keys(%ENV));
return unless @vars;