Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Some suggestions on coding style - a chance to critique

by emilford (Friar)
on Jun 26, 2002 at 22:47 UTC ( #177570=note: print w/ replies, xml ) Need Help??


in reply to Re: Some suggestions on coding style - a chance to critique
in thread Some suggestions on coding style - a chance to critique

Thanks for the tip on allowing someone to specify their own sendmail. I didn't realize the huge security issue involved with that. I'll be sure to make changes on that asap.

return defined $thing and length $thing ? 1 : 0;

What exactly does this do? Is this one of those awkward ways to write an if statement as in old-style C? What is the purpose of the ? 1 : 0?

Finally, what do you have against CGI.pm? I'm looking for both reasons to use it and reasons not to use it. You obvioulsy have a strong opinion in one direction.

Note for PM regulars: no, I still don't like CGI.pm, but I thought it'd be a lot better than the current solution.


Comment on Re: Re: Some suggestions on coding style - a chance to critique
Select or Download Code
Re: Re: Re: Some suggestions on coding style - a chance to critique
by Juerd (Abbot) on Jun 26, 2002 at 23:03 UTC

    Is this one of those awkward ways to write an if statement as in old-style C? What is the purpose of the ? 1 : 0?

    It's the tenary operator. Very C-ish, yes.
    The ? 1 : 0 isn't really needed here, as set() is only used in boolean context, but this clarifies the return value: true or false. Sometimes I write  !! $foo (double boolean negation), sometimes I write  $foo ? 1 : 0 , and sometimes just  $foo .

    Finally, what do you have against CGI.pm? I'm looking for both reasons to use it and reasons not to use it. You obvioulsy have a strong opinion in one direction.

    The short version:
    It is slow (huge), has awful parsing (I just don't like it), a very annoying hybrid interface and too much junk code that is there for (backwards) compatibility. And it doesn't use strict, and has many globals.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      CGI::Lite is a speedier version you may find useful. Reinventing the wheel is fine if there's a need to do so. An awful lot of work and testing went into that wheel in the first place, though, so keep that in mind when you write your replacement. And please release it so the rest of us can take advantage of what you've done.

        An awful lot of work and testing went into that wheel in the first place, though, so keep that in mind when you write your replacement. And please release it so the rest of us can take advantage of what you've done.

        PLP is the result, and it's available for everyone to take advantage of (Note: it's an Apache handler - often not very useful in normal scripts). If you look at how parsing is done, you'll see why I re-invented this wheel. Not that CGI::Lite is bad or anything, I just wanted the data a bit different. I used CGI.pm in my reply because it was already used, and it was the only module I had installed at that machine, at that time.

        - Yes, I reinvent wheels.
        - Spam: Visit eurotraQ.
        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-12-22 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (118 votes), past polls