in reply to Inserting the line references in a text file
As an aside, that's a fairly poor regex to capture "words". It will have trouble with contractions, hyphenated words and words which contain characters not in the current locale. It may be good enough for what you are doing, but you might want to consider using something a little more robust.
Still not perfect, but covering a lot more cases:
use warnings; use strict; while ( my $line = <DATA> ) { while ( $line =~ /(\p{Alnum}+([-']\p{Alnum}+)*)/g ) { my $word = $1; print "$word\n"; # blah } } __DATA__ Tom's wouldn't, they're McCain-Feigngold maņana.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inserting the line references in a text file
by Quicksilver (Scribe) on Feb 28, 2008 at 08:35 UTC |