On Dec 17, Jan Eden said:

>thanks a lot for all the responses. Jeff's explanation of the snippet I
>mentioned in my original message did the trick. The hash-based solution
>is much faster now, although the first attempt (using multiple
>replacements on standard input) is still the fastest.

Well, the first solution might not always work.  Consider the following:

  my %replace = (
    brian => 'jones',
    on => 'off',
  );

If we use the hash approach, then "this is on brian" will be "this is off
jones".  But if we were to do:

  s/brian/jones/g;
  s/on/off/g;

then we'd get "this is off joffes".

It's just something to keep in mind.

>I omitted the sort command since all patterns consist of a single (8-bit)
>character, so I guess your caveat is not applicable. My original message
>was garbled (see above).

Oh, ok.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
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