#!usr/local/bin/perl print ("Enter filename to search to punctuation characters: "); $path=<STDIN>; print ("\n"); open(DATA, "<$path") || die "Couldn't open $path for reading: $!\n"; while (<DATA>) { while (s/([\041-\057]|[\72-\100]|[\133-\140]|[\173-\176])(.*)/$2/) { $char = $1; $wordHash{$char}++; } } while ( ($punctuation, $count) = each(%wordHash) ) { $wordArray[$i] = "$punctuation\t$count"; $i++; print ("$punctuation\t$count\n"); }
hi, the code above searches through a text file and spits out how many of each puntuation character it finds (according to each ASCII octet i have put in the regular expression bit). im after a different way of doing this second loop. so that instead of actually printing out the character it finds it prints out the word equivalent, ie "." equals fullstop, and "," equals comma. i guess id have to use some sort of hash to create a database of ,=comma and .=fullstop and (=open brackets etc. but im not quite sure how to do this... and then relate it to what it finds in the punctuation search. ie - what it does now:
? 1 . 6 , 5 ( 10 ) 10 ; 21 $ 19
what i want it to look like:
question mark 1 fullstop 6 comma 5 open bracket 10 close bracket 10 colon 21 dollar sign 19
cheers, PS sorry about the ambiguity of my last post!

In reply to punctuation search (different!) by Yoda_Oz

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.