
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
- Date: Wed, 18 Jan 2006 18:43:44 +0900
- From: David Riggs <dariggs@example.com>
- Subject: [tlug] Searching for kanji strings, correction to the perl script
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050420 Debian/1.7.7-2
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