my $type= $q->param('type'); $type ||= 'display'; if( 'display' eq $type ) { # output Content-Type: text/html # Output HTML page } elsif( 'download' eq $type ) { # output Content-Type: application/x-download # Output file } else { # Should never get here unless somebody has misconfigured the script or is playing around with the parameters # output Content-Type: text/html # Output HTML page };