CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [aiikahn] Matching regular expressions: Edit Log


Mar 10, 2008, 4:48 PM

Views: 483
Re: [aiikahn] Matching regular expressions

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)

Edit Log:
Post edited by eWish (User) on Mar 10, 2008, 6:25 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives