Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Sorting in Safe compartments under Perl 5.8

Reply
Thread Tools

Sorting in Safe compartments under Perl 5.8

 
 
Zbigniew Fiedorowicz
Guest
Posts: n/a
 
      11-05-2003
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

 
Reply With Quote
 
 
 
 
Zbigniew Fiedorowicz
Guest
Posts: n/a
 
      11-05-2003
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

Zbigniew Fiedorowicz wrote:
> 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.ChDir() not thread-safe; was : Is tempfile.mkdtemp() thread-safe? Gabriel Rossetti Python 0 08-29-2008 08:30 AM
Safe Mode (?) - It is meant to be normal mode but looks like safe mode English Patient Computer Support 3 10-03-2004 11:10 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 06:24 AM
$SAFE = 5 and Safe Ruby Misleading? kirindave@lensmen.net Ruby 1 08-11-2003 11:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57