tag:blogger.com,1999:blog-3861200916183859809.post7314300501023389931..comments2018-04-16T12:09:54.580+05:30Comments on Perl Quiz: Quiz 6: Print alphabet followed by number of times it appears continuously in a string.saurabh2k26http://www.blogger.com/profile/00524123124401905843noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3861200916183859809.post-30066436756207989352014-12-29T20:10:32.050+05:302014-12-29T20:10:32.050+05:30@santosh correction 1: split(//,<>)
correcti...@santosh correction 1: split(//,<>)<br />correction 2, for aaaba, output should be a3b1a1, your solution gives b1a4saurabh2k26https://www.blogger.com/profile/00524123124401905843noreply@blogger.comtag:blogger.com,1999:blog-3861200916183859809.post-6556494044137741272014-12-16T16:32:30.120+05:302014-12-16T16:32:30.120+05:30Another Method:
#!/usr/bin/perl -w
print "Pl...Another Method:<br />#!/usr/bin/perl -w<br /><br />print "Please enter alphabet:";<br />@string = split(/\s+/,<>);<br /><br /><br />foreach $alpha (@string)<br />{<br /> $count{$alpha}++;<br /> #print "$alpha :$count{$alpha}\n";<br />}<br /><br />@alphaRep = keys %count;<br /><br />foreach $beta(@alphaRep)<br />{<br /> print "$beta is came $count{$beta}times\n";<br />}Anonymoushttps://www.blogger.com/profile/00733607240357859549noreply@blogger.comtag:blogger.com,1999:blog-3861200916183859809.post-31031703503433294362014-08-13T18:00:28.813+05:302014-08-13T18:00:28.813+05:30my $input = 'aaabbccccddde';
$input =~ s/...my $input = 'aaabbccccddde';<br /><br />$input =~ s/(([a-z])\2*)/$2 . length($1)/ge;<br /><br />print "$input\n";<br />Dave Crosshttps://www.blogger.com/profile/17165198648105678551noreply@blogger.com