Efektivita
Honza Pazdziora
adelton na informatics.muni.cz
Středa Leden 20 11:43:40 MET 1999
>
> Da se to urcite napsat efektivneji. Jak?
>
> sub rtrim()
> {
> my $string = shift @_;
>
> while( $string =~ s/\s$//g )
> {
> }
>
> return $string;
> }
>
> ltrim se lisi jen regexpu s/^\s//g
>
> Fce trim (orezani z obou stran) je &rtrim( <rim ( $string ));
>
> Cau,
$string =~ s/\s+$//;
Bez toho while. A muzete zkusit use Benchmark na porovnani, jestli je
lepsi shift @_ nebo $_[0].
Na druhou stranu, pokud to opravdu nepotrebujete jako funkci, tak je
bezne to psat v Perlu primo do kodu a nevolat na to funkce.
------------------------------------------------------------------------
Honza Pazdziora | adelton na fi.muni.cz | http://www.fi.muni.cz/~adelton/
The total number of bytes in all expressions in the GROUP BY clause is
limited to the size of a data block minus some overhead. --Oracle SQL Ref.
------------------------------------------------------------------------
Další informace o konferenci Perl