my $file; if(case1) { $file = 'this.html'; } elsif(case2) { $file = 'that.html'; } else { $file = 'error.html'; } print "Content-Type: text/html\n\n"; { open(HTML, $file) or die $!; local $/; # this will make just return the # whole file instead of line by line print ; close HTML; }