Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Searching for kanji strings, correction to the perl script



Dear Tolerant TLUGers,


I have already discovered a error in my perl-lette.

I failed to notice that without a /g switch, it finds only the first one.

Easy to fix, save the match in an array and then foreach down the array:

#!/usr/bin/perl -0777 -n
BEGIN {$w = '[0-9pabc()|。 \n\015]*'}
  @example.com = m/
弟$w子$w有$w稱$w揚$w之$w德
.*$w/gxo;
if (@example.com) {print $ARGV, "\n";
	 foreach $one ( @example.com) {print $one, "\n";}}

David

ps
by changing the regex so that I ignore the leading line numbers (but 
make sure to print out a line number by adding on a .*$w at the end), I 
have speeded it up to faster than a plain grep for a simple case, down 
to about 25 sec. Perl really is pretty darn fast.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links