Salut tout le monde.

Je crée actuellement un site web et j'ai une fonction Perl qui affiche le contenu d'un fichier html, son code est celui-ci :

EDIT : J'avais oublié le reste du code (qui pourrait aider).

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
sub ouvrir_fichier_html {
        my $fichier = shift @_;
        open(my $fh, '<:utf8', $fichier)
                or die 'Impossible d\'ouvrir le fichier en lecture : ' . $! . "\n";
        return $fh;
}
sub afficher_fichier_html {
        my $fh = ouvrir_fichier_html($_[0]);
        while (my $ligne = <$fh>) { print $ligne; }
}
J'ai une autre source generate_html.pl qui s'occupe de la mise en page :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
##Portions de page##
sub debut {
        print $cgi->header,
              $cgi->start_html(-title=>'Site web',
                               -style=>{-src=>'/style.css'});
}
sub banniere        { afficher_fichier_html('/var/www/LW/control/header.php'); }
sub menu_navigation { afficher_fichier_html('/var/www/LW/control/nav.php'); }
sub articles        { afficher_fichier_html('/var/www/LW/control/articles.php'); }
sub auth_form       { afficher_fichier_html('/var/www/LW/control/auth_form.php'); }
sub register_form   { afficher_fichier_html('/var/www/LW/view/register_form.php'); }
sub fin             { print $cgi->end_html; }
sub haut_de_page    { debut; banniere; menu_navigation }
 
##Page entières##
sub index_html    { haut_de_page; articles; fin; }
sub register_html { haut_de_page; register_form; fin; }
sub authent_html  { haut_de_page; auth_form; fin; }
Voici l'exemple du fichier articles.php généré par index.pl qui appelle la fonction index.html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
<?php
	include('sessionInit.php');
	($_SESSION['authent']) ? include('/var/www/LW/view/articles.php') : include('/var/www/LW/view/not_authent_index.html');
?>
Voici à quoi ressemble la page index.pl dans le browser :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>#</title>
<link rel="stylesheet" type="text/css" href="/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<header>
	<div>
		<h1>
			#	
		</h1>
	</div>
</header>
<nav>
	<ul>
		<li>
			<a href='index.pl'>
				Accueuil
			</a>
		</li>
		<li>
			<a href='register.pl'>
				S'enregistrer
			</a>
		</li>
		<li>
			<a href='authent.pl'>
				S'authentifier
			</a>
		</li>
	</ul>
</nav>
<?php
	include('sessionInit.php');
	($_SESSION['authent']) ? include('/var/www/LW/view/articles.html') : include('/var/www/LW/view/not_authent_index.html');
?>
 
</body>
</html>
Lorsque le code php est exécuté en ligne de commande le script s'effectue correctement.

Qu'est -ce que j'ai planté ? Comment faire pour y remédier ?