Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • sub send_headers {
        my $self = shift;
        my $q = $self->query;
        my %actions = ( redirect  => sub { $q->redirect( $self->header_props ) },
                        header    => sub { $q->header($self->header_props()) },
                        none      => sub { return '' },
                   
    • That's not correct in detail. The _default_ action will be executed if the headertype is undef or 0, but what about "illegal" headertypes - e.g. 'foo' ? This would be better: sub send_headers { my $self = shift; my $q = $self->query; my %actions = ( redirect => sub { $q->redirect( $self->header_props ) }, header => sub { $q->header($self->header_props()) }, none => sub { return '' }, _default_ => s
      • Sorry, pushed the wrong button...
        sub send_headers {
            my $self = shift;
            my $q = $self->query;
            my %actions = (
                    redirect     => sub { $q->redirect( $self->header_props ) },
                    header       => sub { $q->header($self->header_props()) },
                    none         => sub { return '' },
                    _default_    => sub { croak "Invalid header_type " . $self->$header_type } );

            my $headertype = exists $actions{$self->header_type} ? $self->header_type : '_default_';
            return $actions{ $headertype }->();
        }