in reply to Re: How to determine if an array passed as an argument to a subroutine is zero-length
in thread How to determine if an array passed as an argument to a subroutine is zero-length

Thanks for your input, people!

Sorry about the lack of code example before. Here's what I've come up with so far:

get_highest_vers(\@vers); sub get_highest_vers { my $vers_index; my @sorted_vers; my @locvers = @_; $#sorted_vers = -1; if ($#locvers == -1) { $highest_vers = 0.00; } else { for ($vers_index = 0; $vers_index <= $#locvers; $vers_index++) { $locvers[$vers_index] =~ s/\.\/v//; $locvers[$vers_index] += 0; } # Sort the archive version numbers and grab the highest one @sorted_vers = sort {$b <=> $a} @locvers; $highest_vers = shift(@sorted_vers); } ($major, $minor) = split(/\./, $highest_vers); }

This seems to work, (although I can't help feeling it's a little ornate!)

Anyway, I'm still having problems when I try and move the subroutine to a seperate module and call it in using the "use Module" construct:

I get a complaint that the argument given in the subroutine call should be an array, not a reference constructor. It also says that no implicit dereferencing is allowed--use the {EXPR} forms as an explicit dereference.

Can anyone advise? BTW, I'm using "diagnostics" and "strict".

-Withnail

  • Comment on Re: Re: How to determine if an array passed as an argument to a subroutine is zero-length
  • Download Code