Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Puzzlement in Splitsville

by Anonymous Monk
on Jun 20, 2005 at 21:32 UTC ( [id://468498]=note: print w/replies, xml ) Need Help??


in reply to Puzzlement in Splitsville

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Puzzlement in Splitsville (use the force luke)
by demerphq (Chancellor) on Jun 21, 2005 at 11:01 UTC

    For question 1, whatever happened to coding things the old-fashioned way?

    Maybe because if we wanted to write verbose error prone code we would stick to C where it would at least be fast? I mean seriously do you really think your solution is easier to read or understand than

    @codons = unpack "(a3)*",$string;

    and

    my @runs; push @runs,$1 while $string=~/((.)\2*)/gs;

    I mean your code has about 5 times the informational density than mine. That says to me that there is 5 times more places to make silly errors and its 5 times more likely that some maintainer will misunderstand and break the code. And as a bonus the perlish code is going to be MUCH faster. I'll leave benchmarking it to you, but I think youll be unpleasantly surprised at how much slower your variants are.

    Even if you did for some weird reason want to avoid the natural perl way to do these things the code you have is less than desirable. Three arg for loop when you could have used for LIST and avoided potential fencepost errors etc.

    And to prove my point a close inspection of your second snippet reveals a subtle error: $start=pos; is wrong. It should $pos as pos is a special keyword used by the regex engine. A mistake that wouldn't have occured had you not been trying to write C code in Perl.

    ---
    $world=~s/war/peace/g

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Puzzlement in Splitsville
by bageler (Hermit) on Jun 21, 2005 at 15:55 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found