Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The Once And Only Once bigot in me would force me to rewrite

my $_name = param('name') || ''; my $_color = param( 'color' ) || '';


my ($_name, $_color) = map {param($_) || ''} qw(name color);

My illogical fear that there would be at least one person in the world called '0' would then force me to rewrite the above as:

my ($_name, $_color) = map {defined($_) ? $_ : ''} map {param($_)} qw(name color);

As for the regex style... Personally I would go for traditional regexes if I was running a tutorial, since this is what most students would come across if they tried to follow up their perl work elsewhere. However that's just my preference - and depends on the audience and what they're expected to do with what their taught ;-)

I would also use the OO style of using CGI since I dislike namespace pollution - but that's just me.

I would also run encode_entities over $color as well as $name. I met a totally evil proxy a few years back that stripped HTML content to 7 bits and have been paranoid ever since!

AFAIK \p{IsAlpha} is exactly the same as using :alpha:.

(and are we ignoring uninitialised value warnings from the print if $name or $color don't match? :-)

In reply to Re: "Correct" program style questions by adrianh
in thread "Correct" program style questions by Ovid

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2017-11-19 18:27 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (282 votes). Check out past polls.