I think the issue you're running into is that if CGI::Carp traps an error and attempts to output the message to the browser before your CGI script has had a chance to output proper CGI headers, you'll get that old familiar problem of attempting to generate output without proper headers.

The solution is for your CGI::Carp handle_errors() subref to handle the outputting of headers too. You may find it helpful to keep a flag that lets you know whether or not you've already output a header. The error handling has to be established in a BEGIN{} block so that compiletime errors will properly be handled too.

Regarding hash slices, consider the following examples:

@hash{ @keynames } = @valuelist; # Assign values to a bunch # of keynames at once. @valuelist = @hash{ @keynames }; # Grab a bunch of values given # a list of keynames. ( $address, $phone ) = @{$people{ $name }}{ 'address', 'phone' }; # Grab individual fields # from a record.

The usefulness of a language feature is just a matter of need and imagination.


Dave


In reply to Re: using CGI, hash slices, and perldoc by davido
in thread using CGI, hash slices, and perldoc by Anonymous Monk

Title:
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, details, 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, summary, 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.