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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |