in reply to RE: reg ex matching 101
in thread reg ex matching 101

What's wrong with the original?

It doesn't handle word boundaries, as you mention, but I don't see much of a difference between the magical assignment to $_ and the explicit assignment to $line.

Besides that, you could just use print "Yeppers!" if /cat/; and print;.

If I'm missing something here, please enlighten me.

Replies are listed 'Best First'.
RE: RE: RE: reg ex matching 101
by 2501 (Pilgrim) on Oct 08, 2000 at 03:40 UTC
    the use of $_ was a 'code to taste' manuever on my part. I use the magical assignments all the time:)
    What I saw was the file being printed out, then the while loop trying to print 'yeppers' each time cat was found.
    While I was unaware that printing the file stream and then trying to call it in the while would fail, I imagined the output to be the full file printing, and then any number of 'Yeppers' one after the other. I was assuming what he wanted to do was print yeppers along with the text instead of one after the other.