Well, let's see:

X:\>perl 11162789.pl Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "1/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. ERRORS = 0 X:\>perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x +64-multi-t hread Copyright 1987-2011, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. X:\>

Line 16 is this one:

return %same == 1 ? 1 : 0;

Prior to Perl 5.25, a non-empty hash in scalar context returned a STRING containing used and allocated buckets, separated by a slash. After that, a hash in scalar context returns the number of keys in the hash. Obviously, you did not consider that. keys %same would always return the number of keys.

And while we are at it, let's see what happens once you leave the 8 bit world and process Unicode strings. Adding the following line to the "TESTING FALSE" lines:

hasSameChars("ABC\x{ABCD}", "ABC\x{CDEF}") == 0 or + $ERRORS++;
... Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Terminating on signal SIGBREAK(21) Use of uninitialized value in join or string at 11162789.pl line 14. Terminating on signal SIGBREAK(21) Use of uninitialized value in join or string at 11162789.pl line 14. X:\>

Yes, it seems that it does not terminate. Actually, it would terminate, after issuing many, many warnings. Much more than I'm willing watch scrolling across my screen.

Line 14 is this line:

"@count"

Let's change my change to use "ABC\x{101}" and "ABC\x{102}" to see what happens:

... Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Use of uninitialized value in join or string at 11162789.pl line 14. Argument "2/8" isn't numeric in numeric eq (==) at 11162789.pl line 16 +. ERRORS = 0 X:\>

Well, it seems you don't know Unicode at all, or you just completely ignored it.

Both is sad.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: Check if string A and B are made up of same chars by afoken
in thread Check if string A and B are made up of same chars by harangzsolt33

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.