artist has asked for the wisdom of the Perl Monks concerning the following question:
Above Code when run gives the errorpackage main; use X; use SORT; my $p = new X(10); my$q = new X(20); my $r = new X(15); foreach my $obj (sort by_id ($p,$q,$r)){ print $obj->id; } package X; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(id); sub new { my $class =shift; my $self = { _id => shift }; bless $self, $class; } sub id { my $self = shift; return $self->{_id}; } 1; package SORT; use X; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(by_id); sub by_id { $a->id <=> $b->id; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: OO and sorting
by tilly (Archbishop) on Jul 26, 2001 at 01:25 UTC | |
|
Re: OO and sorting
by bikeNomad (Priest) on Jul 26, 2001 at 00:58 UTC | |
by artist (Parson) on Jul 26, 2001 at 01:46 UTC | |
|
Re: OO and sorting
by dragonchild (Archbishop) on Jul 26, 2001 at 00:38 UTC | |
|
Re: OO and sorting
by japhy (Canon) on Jul 26, 2001 at 01:55 UTC | |
|
Re: OO and sorting
by suaveant (Parson) on Jul 26, 2001 at 00:40 UTC |