in reply to Regexp for word with underscore in the middle
Your code should have found do_add. This finds do_add or do_delete. Note that case is important. Make the regex /do_(add|delete)/i (note the i) to make it case insensitive.
use warnings; use strict; while (<DATA>) { if (/do_(add|delete)/) { print "Found: $_"; } }
__DATA__ A line of stuff with do_add in it. A line of stuff with do_delete in it. Another line of stuff. The last line of stuff. It has do_add and do_delete. Found: A line of stuff with do_add in it. Found: A line of stuff with do_delete in it. Found: The last line of stuff. It has do_add and do_delete.
|
|---|