in reply to Re: regex patterns
in thread regex patterns
that crashes on me so here is my code that works but doesn't read the whole file.#! perl #! usr/bin/local/perl $file = shift; $pattern = shift; open(MAT, "<$file") or die "bad file name"; my $text = do ( local $/: <MAT> ); while($text =~ /\Q$pattern\E/g) { $x += 1; } print "found $x matches\n"; close(MAT);
thanks#! perl #! usr/bin/local/perl $file = shift; $pattern = shift; open(MAT, "<$file") or die "bad file name"; $text = <MAT>; while($text =~ /\Q$pattern\E/g) { $x += 1; } print "found $x matches\n"; close(MAT);
Height : varies depending on my speed relative to the observer Weight : is a sensation caused by the gravitational wrapping of time-space Age : time is only a persistent illusion
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re3: regex patterns
by Hofmator (Curate) on Feb 07, 2003 at 21:30 UTC | |
by dogbert (Scribe) on Feb 14, 2003 at 23:21 UTC |