
Jasmine
Administrator
Mar 15, 2001, 6:04 AM
Post #1 of 1
(37428 views)
|
How do I process each word on each line?
|
Can't Post
|
|
How do I process each word on each line? Use the split function:
while (<>) { foreach $word ( split ) { # do something with $word here } } Note that this isn't really a word in the English sense; it's just chunks of consecutive non-whitespace characters. To work with only alphanumeric sequences, you might consider
while (<>) { foreach $word (m/(\w+)/g) { # do something with $word here } }
|