Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: providing a callback routine to sort ( $::a $::b )

by Anonymous Monk
on Jan 21, 2014 at 21:53 UTC ( #1071528=note: print w/replies, xml ) Need Help??


in reply to providing a callback routine to sort

Well, ... isn't sufficient for reproducing

Anyway the error message I get is Use of uninitialized value $Foo::a in numeric comparison (<=>) at - line 2.

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; { package Foo; sub Foo::comp { $b <=> $a } } { package Oof; sub Oof::comp { $::b <=> $::a } } sub pomc { $b <=> $a } dd( [ sort { pomc() } 1..10 ] ); dd( [ sort { Foo::comp() } 1..10 ] ); { my @f = 1..10; my $cb = \&Foo::comp; dd( [ sort $cb @f ] ); $cb = \&pomc; dd( [ sort $cb @f ] ); $cb = \&Oof::comp; dd( [ sort $cb @f ] ); } __END__
$Foo::a is not the same as $main::a aka $::a aka perlvar#$a

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2023-05-28 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?