in reply to Count word in my dir

nm...I was thinking that it would matter what the regex would return ... like if you wanted to extract 99 from 359987. but A.M. was just wanting to test if 99 was in $_. my bad..

Replies are listed 'Best First'.
Re: Re: Count word in my dir
by sgifford (Prior) on Jul 31, 2003 at 16:02 UTC
    That's just not correct.
    #!/usr/bin/perl -w use strict; foreach ("WORDHERE", "stuffthenWORDHERE", "WORDHEREthenstuff", "stuffbeforeWORDHEREstuffafter", "wordhere", "no_word_here") { print "$_: "; if($_ =~ /WORDHERE/gi) { print "matches"; } else { print "doesn't match"; } print "\n"; }
    produces
    WORDHERE: matches
    stuffthenWORDHERE: matches
    WORDHEREthenstuff: matches
    stuffbeforeWORDHEREstuffafter: matches
    wordhere: matches
    no_word_here: doesn't match