in reply to Re: Regexp for word with underscore in the middle
in thread Regexp for word with underscore in the middle

the relevant code is
while (<filehandle>) { if (/do_add/) { [some stuff here] } }
It does not execute the code inside the if... but if I change the regexp to /add/ instead... code inside the if is executed, but on a bunch of lines in addition to the do_add line from the input file. (add appears throughout the file)

Replies are listed 'Best First'.
Re^3: Regexp for word with underscore in the middle
by Transient (Hermit) on Aug 18, 2005 at 18:29 UTC
    No issues here...
    #!/usr/bin/perl use strict; use warnings; while (<DATA>) { if ( /do_add/ ) { print "Wow! Got do_add - $_"; } else { print "Awwww - no do_add - $_"; } } __DATA__ do_taxes do_things do_add do_wop
    Output:
    C:\Perl>perl testdo.pl Awwww - no do_add - do_taxes Awwww - no do_add - do_things Wow! Got do_add - do_add Awwww - no do_add - do_wop