in reply to Final Print Statement in Foreach Loop Prints Twice

Here's the script! I'm sorry it's so long
Indeed, 72 lines for finding out if words are anagrams is a bit long. But it's not very difficult to make it significantly shorter:
#!/usr/bin/perl use strict; use warnings; use feature 'say'; say "\nReady to play the anagram game? Excellent.\n\nType your first w +ord or phrase, then hit Enter.\n\n"; chomp (my $aWord = <STDIN>); say "\n\nThanks! Now type your second word or phrase and hit Enter.\n\ +n"; chomp (my $bWord = <STDIN>); say "You typed the same word or phrase twice" and exit if $aWord eq $b +Word; say is_anagram($aWord, $bWord) ? "True" : "False"; sub is_anagram { s/^ +| +$//g for @_; # remove leading or trailing spaces return 0 if length $_[0] != length $_[1]; # words are not anagrams + if not the same length my @words = map {join '', sort split //, lc} @_; return $words[0] eq $words[1]; }
Update: it appears that you deleted your node while I was posting this answer. Why? The answers provided to you don't make sense anymore.