Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > PERL and CSS without using the HTML Link Tag

Reply
Thread Tools

PERL and CSS without using the HTML Link Tag

 
 
Bushido Hacks
Guest
Posts: n/a
 
      10-11-2005
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";

 
Reply With Quote
 
 
 
 
Scott Bryce
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks wrote:

> 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/HT....7/Template.pm
 
Reply With Quote
 
 
 
 
Bushido Hacks
Guest
Posts: n/a
 
      10-11-2005
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.

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks wrote:
> 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

 
Reply With Quote
 
axel@white-eagle.invalid.uk
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
Scott Bryce
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks wrote:

> 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?

 
Reply With Quote
 
Scott Bryce
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks wrote:

> 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 '@'.
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      10-11-2005
"Bushido Hacks" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) oups.com:

> I was hoping to use a list of print statements rather than CGI.


I was hoping to read a coherent post, but then ...

> Put down the 12 sided die for a moment and tell me IF it would work or
> not.


*PLONK*
--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      10-11-2005
Scott Bryce <(E-Mail Removed)> wrote:

> Bushido Hacks wrote:
>
>> 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 even:

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

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

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      10-11-2005
Bushido Hacks wrote:
> 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).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Html page without any Html tag in its source lovecreatesbea...@gmail.com HTML 10 07-29-2007 04:51 AM
HTML.Tag.BASE same as HTML.Tag.A carlbernardi@gmail.com Java 1 11-29-2006 03:41 AM
struts custom tag html:link to show a popup window without addressbar, toolbar & status bar etc sayed.ansarali@gmail.com Java 1 07-10-2006 02:03 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
confused - html validates, css validates but validate css from the html causes errors Titus A Ducksass - AKA broken-record HTML 6 11-15-2004 12:59 PM



Advertisments