> The match condition is number of ; in 1 line 
Output: 
found 14 ; in 1,232 lines
found 13 ; in 7,456 lines
found 12 ; in 2,321 lines

my %line_counts;
while (<>) {
   my $semis = tr/;/;/;
   if ( $semis ) {
      $line_counts{$semis}++;
   }
   else {
       warn("Bad data - no semis: $_");
   }     # if $semis

}    # while <>
foreach my $counts ( sort keys %line_counts ) {
   printf("Found %02d ; in %d lines\n", $line_counts{$counts}, $counts);
}

run on itself, we get
# perl /tmp/ln.pl /tmp/ln.pl
Bad data - no semis: while (<>) {
Bad data - no semis:    if ( $semis ) {
Bad data - no semis:    }
Bad data - no semis:    else {
Bad data - no semis:    }     # if $semis
Bad data - no semis:
Bad data - no semis: }    # while <>
Bad data - no semis: foreach my $counts ( sort keys %line_counts ) {
Bad data - no semis: }
Found 03 ; in 1 lines
Found 01 ; in 2 lines
Found 01 ; in 3 lines



a

Andy Bach
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738  FAX 264-5932

Have you noticed that people whose parents did not have 
children, also tend not to have children?
  - Robert J. Kolker in sci.math, "Re: Genetics and Math-Ability"
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to