Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 goofing around in the Monastery: (5)
As of 2024-06-19 21:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.