Re: Counting regex occurrences

2002-12-14 Thread Randy W. Sims
regex occurrences I found this bit of code somewhere, and I've used it whenever I need to count occurrences of something. It doesn't require any extra temp variables. It works although I don't know why. Perhaps someone can explain exactly what's happening here... #count t

RE: Re: Counting regex occurrences

2002-12-14 Thread Bill Royds -Perl
; Is the same but the first just eliminates the temporary. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Adrian Brinton Sent: Sat December 14 2002 05:58 To: [EMAIL PROTECTED] Subject: Re: Re: Counting regex occurrences I found this bit of code

Re: Counting regex occurrences

2002-12-14 Thread Kris Wolff
On 14.12.2002 11:57 Uhr, "Adrian Brinton" <[EMAIL PROTECTED]> wrote: > > #count the occurrences of "a" > $string = "aaabbbcccddd"; > $count = () = $string =~ /a/g; > print "Count is $count\n"; > This is really cool ! I never ever seen this kind of line. Is there any rule or document snipe or exp

Re: Re: Counting regex occurrences

2002-12-14 Thread Adrian Brinton
ences of "a" $string = "aaabbbcccddd"; $count = () = $string =~ /a/g; print "Count is $count\n"; Adrian Brinton > - Original Message - > From: "Coonfield, Ben CONT" <[EMAIL PROTECTED]> > Date: Thu, 12 Dec 2002 15:12:09 -0500 > To: [EMAIL PROTEC

RE: Counting regex occurrences

2002-12-12 Thread Vuillemot, Ward W
h then get forced to scalar # based on composition of $b $b = ($a =~ tr/a/a/); # verify we counted the number of 'a's in $a print $b; # bye exit; -Original Message- From: Coonfield, Ben CONT [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 12, 2002 12:12 PM To: [EMAIL PROT

Counting regex occurrences

2002-12-12 Thread Coonfield, Ben CONT
It seems like there should be a simpler way to count the number of occurrences of a regular expression. For example: @temp= / Current Value: /g; $count=@temp; I don't really care about @temp, I only want to get the value for $count. So how can I do this without creating a (named) temporary varia