Edward Wijaya wrote:
Hi,

Hello,

I am trying to benchmark these two sorting algorithms.
However running the script below:

$ perl thiscode.pl

gives:
Can't use an undefined value as an ARRAY reference at radix.pl line 23.

However the code execute smoothly with the normal usage.
Only when I use 'cmpthese' the problem occur.

Any idea?

It looks like Benchmark has a problem interpreting the contents of @array. Why it is trying to interpret its contents I don't know.


Change these lines:

#The script runs ok if I remove this 'cmpthese' snippet
cmpthese (-5, {rad   => "radix_sort([EMAIL PROTECTED])",
               nsort => "basic_sort([EMAIL PROTECTED])"
              }
         );

sub basic_sort {

my $array = shift;

sub radix_sort {
    my $array = shift;


To this:

> #The script runs ok if I remove this 'cmpthese' snippet
> cmpthese (-5, {rad   => "radix_sort()",
>                nsort => "basic_sort()"
>               }
>          );

> sub basic_sort {
>
>  my $array = [EMAIL PROTECTED];

> sub radix_sort {
>     my $array = [EMAIL PROTECTED];




John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to