Re: Counting occurences of a char in a line

2005-01-17 Thread Tor Hildrum
On Tue, 18 Jan 2005 01:08:56 +0100, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > foreach my $line () { > if ( $line =~ /^[^,]*(?:,[^,]*){10}$/) ) { > print OUT $line; > } > } > > That is check whether the full string is "something not containing > comma followed by ten times comma

Re: Counting occurences of a char in a line

2005-01-17 Thread Jenda Krynicky
From: Tor Hildrum <[EMAIL PROTECTED]> > I have the following code in a script I'm writing: > > foreach my $line () { > if ( 10 == ($line =~ s/,/,/g) ) { > print OUT $line; > } > } > > Is this poor style? It looks a bit ugly, but I can't figure out a > better way to do it. I'm sure

Re: Counting occurences of a char in a line

2005-01-17 Thread John W. Krahn
Tor Hildrum wrote: Hi, Hello, I have the following code in a script I'm writing: foreach my $line () { if ( 10 == ($line =~ s/,/,/g) ) { print OUT $line; } } Is this poor style? It looks a bit ugly, but I can't figure out a better way to do it. I'm sure there is :) The script will b

RE: Counting occurences of a char in a line

2005-01-17 Thread Bakken, Luke
> Hi, > > I have the following code in a script I'm writing: > > foreach my $line () { > if ( 10 == ($line =~ s/,/,/g) ) { > print OUT $line; > } > } > > Is this poor style? It looks a bit ugly, but I can't figure out a > better way to do it. I'm sure there is :) > The script wil

Counting occurences of a char in a line

2005-01-17 Thread Tor Hildrum
Hi, I have the following code in a script I'm writing: foreach my $line () { if ( 10 == ($line =~ s/,/,/g) ) { print OUT $line; } } Is this poor style? It looks a bit ugly, but I can't figure out a better way to do it. I'm sure there is :) The script will be reused and probably m