Link to home
Start Free TrialLog in
Avatar of elvaaa
elvaaa

asked on

How to print a file

How should I print a file through a SSI HTML document.
<!-- exec cgi="myfile.cgi" -->

and this output goes like this

if date = 01 then
print file=/home/www/mydir/dates-dir/01.html
if date = 02 then
print file=/home/www/mydir/dates-dir/02.html

where the 02.html is going to be inserted as a content inside of the of a SSI HTML document on the fly.

if possible can you show some Perl code to accomplish this task?

Thank you,
 
Avatar of elvaaa
elvaaa

ASKER

Adjusted points to 50
#!/usr/local/bin/perl
$date=[ I don't know where you get the date from? ];
$file="/home/www/mydir/dates-dir/".sprintf("%02d",$date).".html";
die "Can't read $path - $!" unless -r $file;
open(F,"<$file");
while(<F>) {
   # You can do some more stuff here with the file
   print;
}
close(F);

Hope this helps
  Tobias

Avatar of elvaaa

ASKER

YES thank you thoellri! It does work. Post an answer! You are great!
ASKER CERTIFIED SOLUTION
Avatar of thoellri
thoellri

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial