[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Perl spørgsmål



Michael Rasmussen <sslug@sslug> writes:

> sub compare {
> #   my $self = shift;
>     my ($key1, $key2) = @_;

Ja, compare bliver kaldt med to argumenter og hvis du bruger begge
ovenstående linjer ender det første argument i $self og det andet i
$key1. 

Fjern heller linjen med $self så folk ikke bliver forviret over om det
er en metode.

>     lc $key1 cmp lc $key2 ||
>     $key1 cmp $key2;
> }


Måske kunen man endda argumentere for at det ville være endnu
tydligere at skrive:

$DB_BTREE->{compare} = sub {
    my ($a, $b) = @_;
    return lc $a <=> lc $b || $a <=> $b;
}

Så det er klart at "compare"-funktionen hører til DB_File og ikke er
beregnet til at blive kaldt fra andetssted.

//Makholm


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-01-01, 17:38 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *