Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Display Troubles

by thatguy (Parson)
on Oct 08, 2001 at 23:10 UTC ( [id://117530]=note: print w/replies, xml ) Need Help??


in reply to Display Troubles

It would probably be best to change your open to the complete path to the file that the user wants open.
also, since you seem to be using an editor for your html, why not pull the html out of the perl

Look into HTML::Template. It will make site updates much nicer and break less perl. html::template tutorial.

here are the changes I would make:
cgi file:

#!/usr/bin/perl -wT use strict; my $video_info; # Loads the CGI Module use CGI; # creates a new CGI object my $page = new CGI; # This will print a standard HTML header print $page->header; # Grab a named CGI parameter my $value = $page->param("video"); #Open up the file that contains the review of the video open(SEE, "/var/www/docs/$value") or $video_info="$!"; while(<SEE>){ #put data from review into variable $video_info .= "$_"; } #close file close(SEE); #Now print out lots of HyperText Mark-up Language using # HTML::Template my $template = HTML::Template->new(filename => 'my.tmpl'); $template->param(info => $video_info); print $template->output; exit;

and the template:
<HTML> <HEAD> <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Win"> <TITLE>Animetion Station &gt; Video Review &gt; Oh MY Goddess! Volum +e 1</title> <LINK REL="stylesheet" HREF="../Style.css" TYPE="text/css"> </head> <BODY TEXT="#ffffff"> <P STYLE="background-color: #3257b8; width: 350px;"><I><FONT SIZE="+3" FACE="Garamond">Animetion Station</font></i></p> <div id="Bottom"> <P><I><FONT SIZE="+2" FACE="Garamond">Video Review</font></i></p> </div> <P><CENTER>&nbsp;</center></p> <P><TABLE WIDTH="738" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="24"> <TR> <TD WIDTH="67" VALIGN="TOP"> <div class="Standard"> <P><CENTER><A HREF="../index.htm">[Home]</a> <HR> <A HREF="../Gallery.shtml">[Gallery]</a> <HR> <A HREF="../Manga.shtml">[Manga]</a> <HR> <A HREF="../Video_Review.shtml">[Video Reviews]</a> <HR> <A HREF="../Links.shtml">[Links]</a> <HR> <A HREF="../Web_Comic.shtml">[Web Comic]</a></center></td> <TD VALIGN="TOP" WIDTH="270" HEIGHT="131"> </div> </td> <TD WIDTH="382" VALIGN="TOP"> <!-- this is the bit that HTML::Template wants so it knows where to pu +t the value of $video_info --> <TMPL_VAR NAME="info"> <!--VIDEO REVIEW LINKS--> <P STYLE="background-color: darkBlue;"> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fBattle_Skip +per_Vol_1.txt">Battle Skipper Volume One by Ertain</a><BR> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fOMG_Vol_1.t +xt">Oh My Goddess! Volume One by Ertain</a><BR> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fOMG_Vol_2.t +xt">Oh My Goddess! Volume Two by Ertain</a><BR> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fOMG_Vol_3.t +xt">Oh My Goddess! Volune Three by Ertain</a><BR> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fOMG_Vol_4.t +xt">Oh My Goddess! Volume Four by Ertain</a><BR> <A HREF="cgi-bin/Video_Gen.cgi?video=Video_Txt_Files%2fOMG_Vol_5.t +xt">Oh My Goddess! Volume Five by Ertain</a></p> </td> </tr> </table> </body> </html>

-p

Replies are listed 'Best First'.
Re: Display Troubles
by mr_dont (Beadle) on Oct 09, 2001 at 00:27 UTC

    I agree with thatguy, and if you are unsure of the exact path to your file (maybe because you are not the admin or whatever), and if it is in the same place as your script, you can always use the CWD module to grab the name of the current working directory...

    # Load the current working directory module use Cwd; # set $dir to the current directory my $dir = cwd; # print out the pathname print "My file is: $dir/$value\n";
      Sometimes the cwd isn't really what you want, though. If you want to know the directory in which the script resides (rather than the directory one was in when it was executed), a better solution is FindBin.

      -Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://117530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found