Re: Regular Exression help
- From: usenet@xxxxxxxxxxxxxxx
- Date: 27 Apr 2006 11:35:26 -0700
Sandy wrote:
I want to count how many + and - are there in this file.
#!/usr/bin/perl
use strict; use warnings;
my ($plus, $minus);
while (<DATA>) { #you would use a filehandle to hello.c
$plus++ if /^\+/;
$minus++ if /^\-/;
}
print "Plus: $plus \n";
print "Minus: $minus \n";
__DATA__
+ foo
- bar
+ baz
+ bap
- baq
--
http://DavidFilmer.com
.
- References:
- Regular Exression help
- From: Sandy
- Regular Exression help
- Prev by Date: RE: How to test result of an extraction?
- Next by Date: Re: #$ary ???
- Previous by thread: Regular Exression help
- Next by thread: reg exp help
- Index(es):
Relevant Pages
|
|