Sorting in Safe compartments under Perl 5.8

  • Thread starter Zbigniew Fiedorowicz
  • Start date
Z

Zbigniew Fiedorowicz

I've run into problem in using sort under Perl 5.8.0 running under the
Linux Redhat 9.0 distribution. The code works flawlessly under Perl
5.6.0 under Linux Redhat 7.2. Under 5.8.0/RH 9.0 sorting fails with
error messages of the form:

Use of uninitialized value in numeric comparison (<=>) at (eval 2)

I'd be particularly interested in hearing whether this code works under
Perl 5.8.0 under other operating systems.

Here's the code:
----------- cut here ----------------------
#!/usr/bin/perl -w

use strict;
use Safe;

sub PGsort {
local($a,$b);
my $compare = shift;

sort {&$compare($a, $b) } @_;
}


my $cmp = new Safe;
print "Safe version $Safe::VERSION\n";

$cmp->share('&PGsort');
my $string = <<'EOF';

my @list = (4,6,2, 5 ,10, 8, 9 );

my $str = join( " ", PGsort sub {$_[0] <=> $_[1] } , @list );

print $str;

EOF

$cmp->reval($string);
----------- cut here ----------------------

Thanks in advance,
Zbigniew Fiedorowicz
 
Z

Zbigniew Fiedorowicz

Here's another data point (according to private email): the code runs fine
under Perl 5.8.0/SunOS 5.8 with Safe version 2.07
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top