Lars Balker Rasmussen wrote:
>
> Michael Wojciechowski <wojci@cs.auc.dk> writes:
> > Nedenstående stump kode er noget jeg har fundet og som virker fint, men
> > jeg underer mig bare over om man ikke kan skrive noget mere
> > gennemskuligt end "$$" for at få process-id'en af en ens script ?
>
> use English;
_FY!_
>
> $PID eller $PROCESS_ID
>
> Se perldoc perlvar
Fra "perldoc -q slow"
Why does using $&, $`, or $' slow my program down?
Because once Perl sees that you need one of these variables anywhere
in
the program, it has to provide them on each and every pattern match.
The
same mechanism that handles these provides for the use of $1, $2,
etc.,
so you pay the same price for each regex that contains capturing
parentheses. But if you never use $&, etc., in your script, then
regexes
*without* capturing parentheses won't be penalized. So avoid $&, $',
and
$` if you can, but if you can't, once you've used them at all, use
them
at will because you've already paid the price. Remember that some
algorithms really appreciate them. As of the 5.005 release. the $&
variable is no longer "expensive" the way the other two are.
og fra English.pm
# Matching.
*MATCH = *& ;
*PREMATCH = *` ;
*POSTMATCH = *' ;
*LAST_PAREN_MATCH = *+ ;
*LAST_MATCH_START = *-{ARRAY} ;
*LAST_MATCH_END = *+{ARRAY} ;
Dvs, at "use English" definerer ovenstående fy-variable, og derfor
sløver programmet ned.
Hvis det har ændret sig siden "i gamle dage" vil jeg da gerne vide det,
da jeg ikke lige er i stand til at lave faktiske Benchmarks lige nu.
--
Thorbjørn Ravn Andersen "...sound of...Tubular Bells!"
http://bigfoot.com/~thunderbear