Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by Anonymous Monk
on Jan 21, 2014 at 21:53 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2025-06-21 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.