Gossamer Forum
Home : General : Perl Programming :

A little simple perl question regarding Links and site_html.pl

Quote Reply
A little simple perl question regarding Links and site_html.pl
I have a file called leftmenu.html which contains some html codes. Now I want to make a $variable in the site_html.pl file which contains the html in the menufile. What is the best way to do that so that I only have to open that file once ?

Best regards

Wilhelm Andreas Eilertsen
Quote Reply
Re: A little simple perl question regarding Links and site_html.pl In reply to
Do you just want to store the contents of a file in a variable?

if (!$leftmenu) {
open (MENU, "leftmenu.html") or die $!;
$leftmenu = join ("", <MENU&gt Wink;
close MENU;
}

The if statement will make it so the file is only opened once (assuming this will be in some sort of loop).

Hope that helps,

Alex