highlight perl code in html document

A

alexjaquet

Hi, I'm looking for a way to do this, any suggestion I've tried the
following code :
#!C:\Perl\bin\Perl.exe without result.

use CGI;
use strict;
use CGI::Carp qw(fatalsToBrowser);
use warnings;
use Syntax::Highlight::perl ':BASIC';

local our $query = new CGI;
local our $root_dir = "C:/Apache2/Apache2/cgi-bin";
open (FILE, "<$root_dir/answerz.cgi") or die "cannot open file
$root_dir/answerz.cgi";
local our $content;
while (<FILE>) {
$content .= $_;
}
print "Content-type: text/html\n\n";
print format_string($content);

Thx
 
T

Tad McClellan

local our $query = new CGI;
local our $root_dir = "C:/Apache2/Apache2/cgi-bin";
local our $content;


I have asked you this twice before, but you never responded.

It appears that you are misunderstanding something, you should
consider getting a proper understanding.


So, I'll try to help you a third (and last) time:

You should always prefer lexical variables over package variables,
except when you can't.

Why do you think that you cannot use lexical variables there?


If you do not understand the question, then ask a question about
the question.

You have an opportunity here to become a more knowledgeable
Perl programmer.

Do you want to learn something, or continue in ignorance?
 
P

Paul Lalli

Hi, I'm looking for a way to do this, any suggestion I've tried the
following code :
#!C:\Perl\bin\Perl.exe without result.
open (FILE, "<$root_dir/answerz.cgi") or die "cannot open file
while (<FILE>) {
$content .= $_;
}
print "Content-type: text/html\n\n";
print format_string($content);

I'm confused as to what you *thought* this was going to do. You never
specified any kind of formatting options for the module.

Read the docs for the module you're trying to use. More to the point,
read *more* than just the synopsis. You have to read all the way down
to where it talks about the different methods (perhaps set_format, for
example), and the different formatting tokens that are available.

Paul Lalli
 
B

Big and Blue

Hi, I'm looking for a way to do this

So have you considered using, say, perltidy (particulalrly its -html
option) rather than re-inventing the wheel?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top