
eWish
User
Mar 10, 2008, 4:48 PM
Post #4 of 4
(929 views)
|
Re: [aiikahn] Matching regular expressions
[In reply to]
|
Can't Post
|
|
The output you are getting is what you should be getting with the code you are using. You are checking to see the letter 'e' exists in the line not in each of the words in the line. $test holds the entire line. If you want to split it into each of the words you can do something like this.
open (my $FILE, '<', $file_to_open) || die "Can't open file: $!\n"; while (my $line = <$FILE>) { for (grep /place pattern here/, split(/ /, $line)) { print $_, "\n"; } } close ($FILE);
(This post was edited by eWish on Mar 10, 2008, 6:25 PM)
|