Hello informed people...

So, I have a very gooky specification, a program takes in text from the command line; like "Hello, how are you", then saves aforesaid text character by character as a folder.

So H gets turned into '01234.H.something' and , into '01234.Comma.something'.

Another program then scans the folder and reads the folder names with a certain prefix and concatonates everything back together before sending it off to get processed and returning a string of its own to be saved as folder names. (I know, very wierd protocol, not my fault ><).

Problem is:
The data comes out of STDIN fine, or out of the response, and is saved fine into the folder names according to a hash table that maps up all the values. BUT during the read process it gets mangled into something like this:

Hello My Name is Chris: 0ell0 0y0name0i0C0ris

There doesnt appear to be any logic to the mangling, and i'm at a loss as to what is causing it; although it seems to be linked to my hashtable which is being searched like this:

sub findCharacterAsKey { my $loebnerLetter = shift; while (($key, $value) = each %$keymap) { if($loebnerLetter eq $value) { printf("$loebnerLetter maps to $value so returning $key\n"); + return $key; } } }

Any help would be appreciated, thanks.


In reply to File Reading and Hash Accessing that isn't doing what you'd expect. by Chris_Stevens

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.