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.

In reply to Shorter script by Laurent_R
in thread Final Print Statement in Foreach Loop Prints Twice by ScarletRoxanne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.