This code works correctly on Safe 2.09 and perl 5.6.0 under MacOS X.
Zig and I have verified that it does not work on red hat linux
using perl 5.8.0 and Safe 2.09. (The list is not sorted numerically
in that case.)
Is this a feature of all implimentations of perl 5.8.0? I would
appreciate it if someone could run this code under perl 5.8.0 and
a Solaris operating system, or one of the other unix operating systems.
Thanks.
--Mike
################################################# #!/usr/bin/perl -w
use strict; # Lines used on my # Mac to make sure that Safe2.09 was used instead of 2.06 #use lib "."; #require "/Volumes/Riemann/webwork/webwork_sort_testing/Safe.pm";
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
#print $string; #print "next\n\n";
$cmp->reval($string); #output #Safe version 2.09 #2 4 5 6 8 9 10 # perl version is #This is perl, v5.6.0 built for darwin #################################################
<| Post or View Comments |>
|