Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: question regarding using Switch.pm in production use

by grinder (Bishop)
on May 02, 2005 at 16:45 UTC ( [id://453320]=note: print w/replies, xml ) Need Help??


in reply to Re: question regarding using Switch.pm in production use
in thread question regarding using Switch.pm in production use

If I were using source filters, I would be very careful to write easy-to-parse Perl.

The trouble is, even that's not good enough. Someone posted a snippet on p5p in this thread, showing how the current incarnation of Switch gets tripped up by thinking it's in a string instead of code, or vice versa.

The trouble was that the snippet's only sin was that the word 'case' appeared in a comment... Something as arbitrary as that just gives me the willies.

- another intruder with the mooring in the heart of the Perl

  • Comment on Re^2: question regarding using Switch.pm in production use

Replies are listed 'Best First'.
Re^3: question regarding using Switch.pm in production use
by Forsaken (Friar) on May 02, 2005 at 17:16 UTC
    I've had similar experiences quite a while ago, just after having discovered Perl. Before then I'd mainly been playing around with C, so discovering there was a way to emulate Switch made me quite a happy camper. Initially it all worked fine, and then things just started going funky. Quite dazzled, I finally ended up replacing the entire Switch by a huge(and i do mean huge, a couple hundred possibilities) if-elsif-elsif-else contraption which worked exactly the way I wanted it to. Never really looked back after that. If something doesn't work exactly the way it is supposed to work, especially when there's a perfectly good alternative, why take the risk?

    To stray from the topic for a moment, I can't think of a reason why it would be impossible to implement a form of switch in pure Perl though. It'd likely be a lot slower than if-elseif-else, but it'd make for a nice intellectual challenge ;-)

    Obviously someone already rose to the challenge, as I could have predicted had I turned my brain up a notch for just a second there. Seems that someone also happened to post just before I did...

    Remember rule one...
Re^3: question regarding using Switch.pm in production use
by Roy Johnson (Monsignor) on May 02, 2005 at 16:59 UTC
Re^3: question regarding using Switch.pm in production use
by Anonymous Monk on May 04, 2005 at 16:00 UTC
    The trouble is, even that's not good enough. Someone posted a snippet on p5p in this thread, showing how the current incarnation of Switch gets tripped up by thinking it's in a string instead of code, or vice versa.
    I don't think that's much of a problem. It's not that your code is different each time it's run. Your code is fixed, and each time it's run, it's the same input to the source filter. It's simple to test see whether the output is correct, or garbage. If the latter, fix your input, or fix your filter.

Log In?
Username:
Password:

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

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

    No recent polls found