Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: simple table join script

by sauoq (Abbot)
on Jun 01, 2012 at 14:44 UTC ( #973789=note: print w/ replies, xml ) Need Help??


in reply to Re^3: simple table join script
in thread simple table join script

Yes - it SORTS them.

Where did he say changing the order in any manner was what he wanted? The issue is that your code essentially requires reordering in some manner because of your poor choice to use hashes which will destroy the original order. You left yourself with the choice to either sort or go with whatever reordering perl gives you.

That's not a nit. Not being able to retain the original order is a fundamental issue. Perhaps he doesn't need to. He didn't say. But if he does need to, your code is worthless.

The efficiency issue may or may not be of practical importance. But its only an issue at all because of the same aforementioned poor design decision. The straight forward approach I showed isn't better because it's more efficient... it's more efficient because it's better.

Correction - it splits on WHITESPACE, that includes tab.

That's right. And thanks for picking a nit with my point... I like precision. It's still a potential problem because he didn't specify whether his fields could have other whitespace... and if they did, your code would break. That's a little less data tolerant, arguably, than some warnings on blank lines.† I called it "minor" because it is so easily corrected, unlike your code's other issues.

Note that adding sorting to the straight forward approach is easily done with a single sort if desired.

Note also that skipping blank lines is easily added to the straight forward approach with an appropriately placed next unless /\S/; or similar.

† Warnings on blank lines may actually be desirable. It's often a good think to throw a warning on data anomalies.

-sauoq
"My two cents aren't worth a dime.";


Comment on Re^4: simple table join script
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://973789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-09-22 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (191 votes), past polls