Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I was wanting something like this, so it was good to find. So how has 12 years changed things other than it still works?

Tech note D is of interest:

Creating the word signature with
   pack "C*", sort unpack "C*", $_
is faster than using
   join "", sort split //, $_;
With Perl 5.14.2, the join/sort/split version is actually faster now, only by a few hundredths of a second on my machine, but it is faster. This is on 917K words. It also generates a correct signature, while the pack version generates a bad signature. Changing the last line to foreach(sort(keys(%words))) { print "$_- $words{$_}\n"; } allows us to compare:
  • pack gives: deoab- abode adobe
  • split gives: abdeo- abode adobe
The pack version works because it orders letters in the same way, but it doesn't order them in alphabetical order like it's supposed to. I'm not sure if this is a result of changes to perl as it's advanced thru time, or if it was that way originally. I don't have a version of perl from back in 2001 to test anyway.

I found the key generation error because I actually want the key to be available and need the letters to be in alphabetical order for another program.

Thanks for sharing!


In reply to Re: Perl's pearls by kbrannen
in thread Perl's pearls by gmax

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-19 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found