diff --git a/lib/App/ClusterSSH/Base.pm b/lib/App/ClusterSSH/Base.pm index f5613ee..58a1d47 100644 --- a/lib/App/ClusterSSH/Base.pm +++ b/lib/App/ClusterSSH/Base.pm @@ -304,13 +304,13 @@ sub parent { sub sort { my $self = shift; - my $sort = sub { sort @_ }; - - return $sort unless $self->config()->{'use_natural_sort'}; - # if the user has asked for natural sorting we need to include an extra # module - if ( $self->config()->{'use_natural_sort'} ) { + my $config = $self->config(); + + # Make sure the configuration object has been set correctly before + # referencing anything + if ( ref $config eq "HASH" && $config->{'use_natural_sort'} ) { eval { Module::Load::load('Sort::Naturally'); }; if ($@) { warn( @@ -318,16 +318,17 @@ sub sort { ); } else { - $sort = sub { Sort::Naturally::nsort(@_) }; + my $sort = sub { Sort::Naturally::nsort(@_) }; + return $sort; } } + my $sort = sub { sort @_ }; return $sort; } 1; - =head1 METHODS These extra methods are provided on the object