Skip to content

Commit 713a9fb

Browse files
committed
Modernize attributes.pm for v5.40
* use v5.40 * `our` on package globals * Signatures on subs * Lexical subs when not required to be visible
1 parent 4f14c5b commit 713a9fb

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

ext/attributes/attributes.pm

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
package attributes;
1+
package attributes 0.37;
22

3-
our $VERSION = 0.36;
3+
use v5.40;
44

5-
@EXPORT_OK = qw(get reftype);
6-
@EXPORT = ();
7-
%EXPORT_TAGS = (ALL => [@EXPORT, @EXPORT_OK]);
8-
9-
use strict;
5+
our @EXPORT_OK = qw(get reftype);
6+
our @EXPORT = ();
7+
our %EXPORT_TAGS = (ALL => [@EXPORT, @EXPORT_OK]);
108

119
sub croak {
1210
require Carp;
@@ -28,27 +26,24 @@ my %msg = (
2826
const => 'Useless use of attribute "const"',
2927
);
3028

31-
sub _modify_attrs_and_deprecate {
32-
my $svtype = shift;
29+
my sub modify_attrs_and_deprecate ($svtype, @args) {
3330
# After we've removed a deprecated attribute from the XS code, we need to
3431
# remove it here, else it ends up in @badattrs. (If we do the deprecation in
3532
# XS, we can't control the warning based on *our* caller's lexical settings,
3633
# and the warned line is in this package)
3734
grep {
3835
$deprecated{$svtype} && /$deprecated{$svtype}/ ? do {
39-
require warnings;
4036
warnings::warnif('deprecated', "Attribute \"$1\" is deprecated, " .
4137
"and will disappear in Perl 5.28");
4238
0;
4339
} : $svtype eq 'CODE' && exists $msg{$_} ? do {
44-
require warnings;
4540
warnings::warnif(
4641
'misc',
4742
$msg{$_}
4843
);
4944
0;
5045
} : 1
51-
} _modify_attrs(@_);
46+
} _modify_attrs(@args);
5247
}
5348

5449
sub import {
@@ -64,7 +59,7 @@ sub import {
6459
if defined $home_stash && $home_stash ne '';
6560
my @badattrs;
6661
if ($pkgmeth) {
67-
my @pkgattrs = _modify_attrs_and_deprecate($svtype, $svref, @attrs);
62+
my @pkgattrs = modify_attrs_and_deprecate($svtype, $svref, @attrs);
6863
@badattrs = $pkgmeth->($home_stash, $svref, @pkgattrs);
6964
if (!@badattrs && @pkgattrs) {
7065
require warnings;
@@ -82,7 +77,7 @@ sub import {
8277
}
8378
}
8479
else {
85-
@badattrs = _modify_attrs_and_deprecate($svtype, $svref, @attrs);
80+
@badattrs = modify_attrs_and_deprecate($svtype, $svref, @attrs);
8681
}
8782
if (@badattrs) {
8883
croak "Invalid $svtype attribute" .
@@ -92,10 +87,9 @@ sub import {
9287
}
9388
}
9489

95-
sub get ($) {
96-
@_ == 1 && ref $_[0] or
90+
sub get ($svref) {
91+
ref $svref or
9792
croak 'Usage: '.__PACKAGE__.'::get $ref';
98-
my $svref = shift;
9993
my $svtype = uc reftype($svref);
10094
my $stash = _guess_stash($svref);
10195
$stash = caller unless defined $stash;

0 commit comments

Comments
 (0)