John Doe wrote:
Am Montag, 2. Mai 2005 03.49 schrieb [EMAIL PROTECTED]:

John,

the reg exp s <-+> ();
              ^
was changed to

     y/sg//;;
               y/-//d;
               s{\w+} ();
to exclude the spaces and use y... thx
why are thre operators y or tr more efficient since these operators do not
use pattern matching?

Don't know the internal details, but tr needs no backtracking, capturing and such, it can simply take a char after the other and replace it with another one. So the implementation of the algorithm must be much much easier.

tr/// does not use regular expressions and does not interpolate variables because it is only evaluated at compile time therefore it has less overhead then m// and s///.


perldoc perlop

[snip]

         Because the transliteration table is built at compile time, neither
         the SEARCHLIST nor the REPLACEMENTLIST are subjected to double
         quote interpolation.  That means that if you want to use variables,
         you must use an eval():



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to