Gossamer Forum
Home : General : Perl Programming :

novice opening file question

Quote Reply
novice opening file question
hey, i have a slight problem. i have different cgi files which all open different files to load one common html template. the problem is that i want to send the session id with every url click. becuase of the way it prints each line, it prints "$variable" instead of the value of $variable. does anyone have any ideas how to get around this?

open(READ,'<',"menu/html01.dat")|| warn "Can't open html01.dat";
while($line = <READ>) {
print $line;
}
close READ;



thanks
Quote Reply
Re: [pedge] novice opening file question In reply to
Can we see your actual code in the context of your program? You shouldn't get "$variable" printed unless you single quoted somewhere.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [pedge] novice opening file question In reply to
Did you check the contents of html01.dat ?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] novice opening file question In reply to
what do u mean by that? here is html01.dat if thats what u mean. it prints the following html:
/cgi-bin/home.cgi?catagory=0&content=0&session=$session&user=$user

instead of (for example):

/cgi-bin/home.cgi?catagory=0&content=0&session=c9f0f895fb98ab9159f51fd0297e236d&user=c51ce410c124a10e0db5e4b97fc2f39


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK title="Style" href="/files/style.css" type="text/css" rel="stylesheet">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<table width="650" border="0" cellspacing="0" cellpadding="1" bgcolor="#000099">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--1st cell-->
<td width="150">
<a href="/cgi-bin/home.cgi?catagory=0&content=0&session=$session&user=$user">
<img src="/files/logo.gif" alt="Home" border="0"></a>
</td>
<!--End 1st cell-->
Quote Reply
Re: [pedge] novice opening file question In reply to
Yeah, but where is the html01.dat file written? Its not the reading part of the script that is failing. Its most likely how you are writing the file contents to html01.dat (as Phillip said, you may have used '$var' to quote your variables, or even used q| |, which stops variables from being parsed).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] novice opening file question In reply to
oh ok - hmtl01.dat is a file in another folder. however its not been written (which is probably where my problem is). its just a files will some html content in it. i just want to have a template for my whole website. change that one file and all the website is changed.
Post deleted by Andy In reply to
Quote Reply
Re: [pedge] novice opening file question In reply to
I think I see your problem. Try this;

Just before;

Code:
print $line;

...add....

Code:
$line =~ s/\$user/$user/gi;
$line =~ s/\$session/$session/gi;

That should work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] novice opening file question In reply to
it worked!!!
thanks - u have saved me from having to do loads of work.
Quote Reply
Re: [pedge] novice opening file question In reply to
Glad to hear it Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!