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

Re^3: Deleting duplicate lines from file

by blazar (Canon)
on Feb 17, 2006 at 07:57 UTC ( [id://530928]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^2: Deleting duplicate lines from file
in thread Deleting duplicate lines from file

It works nearly in the same exact way as the code you already asked about except that:

  1. the flow control is syntactically (but not logically!) different;
  2. it doesn't do a check on the actual strings, but on a checksum computed for them which gives a sufficient condition for two of them to be different. That is, if the checksums are different, then the strings will be different too, while the converse does not hold: different strings may have the same checksums (but we rely on the confidence that such occurrencies are rare enough), hence => my remarks

Then you wrote:

For example, I don't understand this line:
my (@lines, %line_md5);

Oh my! Please tell me you're joking!! I see that you have 204 writing as of now. That's quite surprising... maybe you're not really programming in Perl, but in some vaguely similar language. What is it precisely that you do not understand?

Replies are listed 'Best First'.
Re^4: Deleting duplicate lines from file
by Win (Novice) on Feb 17, 2006 at 09:48 UTC
    The question is.

    Why use
    my (@lines, %line_md5);
    when you can use
    my @lines; my %line_md5:
    I don't really see that there is any point in grouping them together like that. I am thinking of putting a moto on my messages: Keep it simple when possible. Go complex when required.
      Both are simple. Concentrate on your problem
      [slightly edited and fixed a typo: Perl 5 doesn't make that much use of the colon!] The question is my (@lines, %line_md5); when you can use  my @lines; my %line_md5;

      Because it's simpler, cleaner, easier to type and to read, and groups together correlated variables maybe?

      I don't really see that there is any point in grouping them together like that. I am thinking of putting a moto on my messages: Keep it simple when possible. Go complex when required.

      Indeed! Just be aware that the World's concept of "complex" is not bound to match Win's authoritative one...

      PS: here's a motto: "don't put motos on your messages". Oh, or... was it all about Moto? This would explain a lot of things... but no: PM is definitely about Perl.

        Because it's simpler

        Sorry neither are simple. Simplest would be:

        my @lines; my %line_md5;

        Here is clearly readable. There are no troubling lists to have to scan. Each one is on their own line. Simple and readble that is what people's code should be. Of course I wouldn't expect many on PM to understand that, given how much they love the Obfuscation section and how many ++ they give obfuscated code.

        (and yes I'm posting as anon to avoid the -- that you morons will give this post).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://530928]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.