PERL and CSS without using the HTML Link Tag

B

Bushido Hacks

Hello everyone,

I would like to know if I can create a work around to trick PERL into
processing a CSS stylesheet WITHOUT using the LINK tag.

I like to use "@import url(css_file.css);" inside the STYLE tags in the
header.

In the past, I figured out that if you tell PERL to read a text file
with various HTML tags, the HTML tags will proceess. My theory is,
that I think I can get away wthing this same trick if I tell PERL to
read a short text file that contains the string "@import" and nothing
more. This way PERL does not assume that "@import" is an array and
because "\@import" does not process because PERL assumes the "\@" to be
an escape character.

Useing the following examples, I would like to know if this will work
or not:

[file 1: css_import.txt: a short text file with the "@import" string]
@import
[file 2: read_css.pl: the perl file that will process css_import.txt]
#!/usr/bin/perl -w

$css_file = "bh_styles.css";

$import_css = "css_import.txt"; # just a text file that contains string
"@import".
open(CSS,$import_css) || die("ERROR! Could not open $import_css.");
$import_string = <CSS>;
close(CSS);
chomp($import_string);
$import_string .= " url($css_file);";

print "Content-type:text/html\n\n<html><head><style
type=\"text/css\">\n$import_string\n</style>\n";
print "</head><body>\n";
print "<table>\n";
print "<tr><th>r0c0</th><th>r0c1</th></tr>\n";
print "<tr><td>t1c0</td><td>r1c1</td></tr>\n";
print "</table>\n";
print "</body></html>\n";
 
S

Scott Bryce

Bushido said:
Hello everyone,

I would like to know if I can create a work around to trick PERL into
processing a CSS stylesheet WITHOUT using the LINK tag.

Perl does not process CSS stylesheets. Perl does not know what a LINK
tag is.

I like to use "@import url(css_file.css);" inside the STYLE tags in the
header.

Wonderful! But that is an HTML issue, not a Perl issue.

In the past, I figured out that if you tell PERL to read a text file
with various HTML tags, the HTML tags will proceess.

No. Perl does not "process" HTML tags. How could it? How could text in a
scalar variable be bold? or italic? or lined up in tables?

My theory is,
that I think I can get away wthing this same trick if I tell PERL to
read a short text file that contains the string "@import" and nothing
more. This way PERL does not assume that "@import" is an array and
because "\@import" does not process because PERL assumes the "\@" to be
an escape character.

This is total nonsense. Perl makes no assumptions about a string of
characters just because one of the characters is an '@.'

Useing the following examples, I would like to know if this will work
or not:

<code snipped>

I don't know what problem you are trying to solve, but I suspect that
this will serve your needs better than what you are trying to do.

http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm
 
B

Bushido Hacks

I was hoping to use a list of print statements rather than CGI.
Put down the 12 sided die for a moment and tell me IF it would work or
not.
 
P

Paul Lalli

Bushido said:
I was hoping to use a list of print statements rather than CGI.

.... this is the equivalent of saying "I was hoping to use an orange
instead of a protractor". They are wholly completely different tools.
What, exactly, are you trying to accomplish?
Put down the 12 sided die for a moment

Yes, definately. Insulting the people from whom you are requesting
help is *always* a good idea.
and tell me IF it would work or not.

Well, since you didn't quote any context in your apparent reply (have
you read the Posting Guidelines for this group), I have no idea what
"it" is. However, this question always has the same answer: What
happened when you tried it?

Paul Lalli
 
A

axel

Bushido Hacks said:
I like to use "@import url(css_file.css);" inside the STYLE tags in the
header.
In the past, I figured out that if you tell PERL to read a text file
with various HTML tags, the HTML tags will proceess. My theory is,
that I think I can get away wthing this same trick if I tell PERL to
read a short text file that contains the string "@import" and nothing
more. This way PERL does not assume that "@import" is an array and
because "\@import" does not process because PERL assumes the "\@" to be
an escape character.
Useing the following examples, I would like to know if this will work
or not:
[file 1: css_import.txt: a short text file with the "@import" string]
@import
[file 2: read_css.pl: the perl file that will process css_import.txt]
#!/usr/bin/perl -w
$css_file = "bh_styles.css";
$import_css = "css_import.txt"; # just a text file that contains string
"@import".
open(CSS,$import_css) || die("ERROR! Could not open $import_css.");
$import_string = <CSS>;
close(CSS);
chomp($import_string);
$import_string .= " url($css_file);";
print "Content-type:text/html\n\n<html><head><style
type=\"text/css\">\n$import_string\n</style>\n";
print "</head><body>\n";
print "<table>\n";
print "<tr><th>r0c0</th><th>r0c1</th></tr>\n";
print "<tr><td>t1c0</td><td>r1c1</td></tr>\n";
print "</table>\n";
print "</body></html>\n";

Er... why did you not actually try it to see if it worked?

Yes it does work if the line 'just a text file that contains...' is
fixed (yes, I know that you probably formatted the programme for
Usenet).

Axel
 
S

Scott Bryce

Bushido said:
I was hoping to use a list of print statements rather than CGI.

Maybe you should tell us what you think CGI is.

Put down the 12 sided die for a moment
?????

and tell me IF it would work or not.

Did you try it? Did it work?

What are you trying to accomplish?
 
S

Scott Bryce

Bushido said:
Hello everyone,

Hello again.

If I am understanding your problem correctly, you are trying to prevent
Perl from trying to interpolate @import when it is inside of a double
quoted string.

If I am correct, you are jumping through far too many hoops.

Is there a reason why you can't just:

$import_string = qq(\@import url(http://path_to_my/style.css));

or

print "<style> type=\"text/css\">\n\@import
url(http://path_to_my/style.css)\n</style>\n";


(I am not sure what is going to wrap where when I post this. The above
code should be one line.)

If this is not the problem you are trying to solve, can you please
explain what problem you ARE trying to solve? You have asked us if your
solution is going to work, but your problem description is confusing.

You seem to think that Perl will interpolate "\@" as an escape. It
won't. It will interpolate it as '@'.
 
J

John Bokma

Scott Bryce said:
Hello again.

If I am understanding your problem correctly, you are trying to prevent
Perl from trying to interpolate @import when it is inside of a double
quoted string.

If I am correct, you are jumping through far too many hoops.

Is there a reason why you can't just:

$import_string = qq(\@import url(http://path_to_my/style.css));

or even:

$import_string = '@import url(http://example.com/style.css)';

print <<HTML;
<style>
$import_string
</style>
:
:
:
HTML
 
U

usenet

Bushido said:
I was hoping to use a list of print statements rather than CGI.
Put down the 12 sided die for a moment and tell me IF it would work or
not.

Perl isn't really suited to printing and parsing things (Perl was
originally written as a language to monitor runaway processes on
mainframes, don't you know?). You should be using a different language
that does a better job of extracting and reporting (anything but Ruby).
You will probably find usenet groups dedicated to those other
languages where you may be able to get some help (because you won't get
it here).
 
R

Richard Gration

(Perl was
originally written as a language to monitor runaway processes on
mainframes, don't you know?)

Really? Citation? I've always thought the anecdote was " ... when awk ran
out of steam" or close to.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top