Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8787ab9

Browse files
author
Duncan Ferguson
committedOct 15, 2024·
Fix hash reference error on perl > 5.38
Fix a reference issue on hash variables which is now stricter on later versions of perl
1 parent 4d34e53 commit 8787ab9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

‎lib/App/ClusterSSH/Base.pm

+8-7
Original file line numberDiff line numberDiff line change
@@ -304,30 +304,31 @@ sub parent {
304304
sub sort {
305305
my $self = shift;
306306

307-
my $sort = sub { sort @_ };
308-
309-
return $sort unless $self->config()->{'use_natural_sort'};
310-
311307
# if the user has asked for natural sorting we need to include an extra
312308
# module
313-
if ( $self->config()->{'use_natural_sort'} ) {
309+
my $config = $self->config();
310+
311+
# Make sure the configuration object has been set correctly before
312+
# referencing anything
313+
if ( ref $config eq "HASH" && $config->{'use_natural_sort'} ) {
314314
eval { Module::Load::load('Sort::Naturally'); };
315315
if ($@) {
316316
warn(
317317
"natural sorting requested but unable to load Sort::Naturally: $@\n"
318318
);
319319
}
320320
else {
321-
$sort = sub { Sort::Naturally::nsort(@_) };
321+
my $sort = sub { Sort::Naturally::nsort(@_) };
322+
return $sort;
322323
}
323324
}
324325

326+
my $sort = sub { sort @_ };
325327
return $sort;
326328
}
327329

328330
1;
329331

330-
331332
=head1 METHODS
332333
333334
These extra methods are provided on the object

0 commit comments

Comments
 (0)
Please sign in to comment.