I did not notice the words "as I'm sure my teacher would iterate" in the original post, and have therefore removed my complete ready-to-use answer. Damn, a question I answered correctly too :)
As a replacement, I offer some advice. Don't ask others to do your homework. Ask for pointers as to where to look the information up and do the work yourself. I'll pretend that's what you asked of us and give you the pointers:
- split will allow you to split a string using a pattern or character(s). Your example will make good use of a line such as split('', $string);. The '' splits a string on every character.
- join is split's evil twin. Your example might want to use join('', $sorted_letters);.
- sort: Guess what? You do want to use Perl's sorting functions. They make life easy. Specifically, learn the difference between <=> and cmp for comparing. Also, you'll want to use either lc or uc to sort alphabetically instead of by ASCII value.
- my $line = <STDIN>; will get a line of text (ending in a newline "\n") from the command line.
- chomp: Will remove the newline from a line of text. Using it to remove the newline from <STDIN> will be useful.