PERL and CSS without using the HTML Link Tag

Discussion in 'Perl Misc' started by Bushido Hacks, Oct 11, 2005.

  1. 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";
     
    Bushido Hacks, Oct 11, 2005
    #1
    1. Advertising

  2. Bushido Hacks

    Scott Bryce Guest

    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/HTML-Template-2.7/Template.pm
     
    Scott Bryce, Oct 11, 2005
    #2
    1. Advertising

  3. 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.
     
    Bushido Hacks, Oct 11, 2005
    #3
  4. Bushido Hacks

    Paul Lalli Guest

    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
     
    Paul Lalli, Oct 11, 2005
    #4
  5. Bushido Hacks

    Guest

    Bushido Hacks <> 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
     
    , Oct 11, 2005
    #5
  6. Bushido Hacks

    Scott Bryce Guest

    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?
     
    Scott Bryce, Oct 11, 2005
    #6
  7. Bushido Hacks

    Scott Bryce Guest

    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 '@'.
     
    Scott Bryce, Oct 11, 2005
    #7
  8. "Bushido Hacks" <> wrote in
    news::

    > 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 <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 11, 2005
    #8
  9. Bushido Hacks

    John Bokma Guest

    Scott Bryce <> 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 :)
     
    John Bokma, Oct 11, 2005
    #9
  10. Bushido Hacks

    Guest

    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).
     
    , Oct 11, 2005
    #10
  11. On Tue, 11 Oct 2005 11:56:05 -0700, usenet wrote:
    > (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.

    --
    Yeah, well. I also cook.
     
    Richard Gration, Oct 12, 2005
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    941
    Kevin Spencer
    May 17, 2005
  2. shruds
    Replies:
    1
    Views:
    931
    John C. Bollinger
    Jan 27, 2006
  3. Replies:
    1
    Views:
    6,113
    Andrew T.
    Jul 10, 2006
  4. Replies:
    1
    Views:
    421
    Andrew Thompson
    Nov 29, 2006
  5. Replies:
    10
    Views:
    601
Loading...

Share This Page