[Cascavel-pm] Teste para "Perl Job Developer"

Solli Honorio shonorio em gmail.com
Terça Janeiro 2 04:57:48 PST 2007


>
> > A variável $& será populada com isso porque ela guarda o valor do
> > último match de uma expressão regular. Na prática, seu uso é
> > desaconselhado pois ela infere problemas de performance em todo o
> > aplicativo do seu uso pra frente.
>
>
> Sério ? Eu não tinha este informação de performance... então não é
> aconcelhável utilizar o $& nos programas ? Deve apenas fazer a atribuição
> "my $a = $&" !
>

*Lendo o perlre encontrei isto...
WARNING*: Once Perl sees that you need one of
$&<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>,
$` <file:///C:/Perl/html/lib/Pod/perlvar.html#item___>, or
$'<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>anywhere in the
program, it has to provide them for every pattern match.
This may substantially slow your program. Perl uses the same mechanism to
produce $1, $2, etc, so you also pay a price for each pattern that contains
capturing parentheses. (To avoid this cost while retaining the grouping
behaviour, use the extended regular expression (?: ... ) instead.) But if
you never use $& <file:///C:/Perl/html/lib/Pod/perlvar.html#item___>,
$`<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>or
$' <file:///C:/Perl/html/lib/Pod/perlvar.html#item___>, then patterns *
without* capturing parentheses will not be penalized. So avoid
$&<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>,
$' <file:///C:/Perl/html/lib/Pod/perlvar.html#item___>, and
$`<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>if you can, but
if you can't (and some algorithms really appreciate them),
once you've used them once, use them at will, because you've already paid
the price. As of 5.005,
$&<file:///C:/Perl/html/lib/Pod/perlvar.html#item___>is not so costly
as the other two.
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://mail.pm.org/pipermail/cascavel-pm/attachments/20070102/e617528f/attachment.html 


Mais detalhes sobre a lista de discussão Cascavel-pm