Created
May 27, 2015 07:22
-
-
Save alexws54tk/7d5a7a9ac9764b27b684 to your computer and use it in GitHub Desktop.
Count lelters in entered text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
print "Enter text: "; | |
my $text = <>; | |
chomp($text); | |
my @letters=(); | |
my @chars=split(//,$text); | |
for my $char (@chars) { | |
$letters[ord($char)]++; | |
} | |
print "Letters in text\n"; | |
for(my $letter=0; $letter <= $#letters+1; $letter++) { | |
if ($letters[$letter]) { | |
print "Letter '".chr($letter)."':".$letters[$letter]."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment