On Wed, 13 Jun 2001, Michael Cartwright <[EMAIL PROTECTED]> wrote,

> However, I need it in Perl. Could someone help me with what would this look
> like in Perl?
>
> Thanks,
> Michael
>
> <?php
>  $FileName=$HTTP_GET_VARS["FileName"];
>
>  if(!$FileName)
>  {
>   $FileName="example";
>  }
>  $FileName.=".opx";
>  header("Content-type: application/x-opx");
>  readfile($FileName);
> ?>

#!/usr/bin/perl -w

use strict;
use CGI ':standard';

my $file = param('FileName') || 'example';
$file .= '.opx';

if (open OPX, $file) {
    print header(type => 'application/x-opx');
    print <OPX>;
    close OPX;
}
else {
    print
        header,
        start_html('Error'),
        b('Sorry, got problem when showing the content'),
        end_html;
    print STDERR "failed to read $file: $!\n"; # goes to error log
}

__END__

-- 
s::a::n->http(www.trabas.com)

Reply via email to