usr bin perl -w use strict use Data Dumper my earch my calar aaaaaabbs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/perl -w
use strict;
#use Data::Dumper;
my $earch = 'a';
my $calar = 'aaaaaabbsb';
my $ount = 0;
foreach my $c (split '' => $calar) {
( $c eq $earch )?++$ount:1;
}
print $ount;