Paths question

Discussion in 'Perl' started by Jim Rendant, Sep 30, 2003.

  1. Jim Rendant

    Jim Rendant Guest

    I am having a problem with programming in perl using paths to style sheets
    and other static pages. I need a little clarification

    My scenario

    root directory | - /var/www
    html directory | - /html FULL PATH - /var/www/html
    images dir | - /images -
    /var/www/html/images
    cgi-bin dir | - /cgi-bin -
    /var/www/cgi-bin
    perl scripts dir | -/perl -
    /var/www/cgi-bin/perl

    The PERL directory holds programs that create pages on the fly by reading
    both dynamic data and snippets of the final html page. The page is assembled
    by reading a snippet file and then inserting dynamic data and reading
    another snippet. I PRINT the snippet to Standard Out which is the web page
    itself.

    My CSS page is stored in my /var/www/html directory. In my HTML text stored
    in the /var/www/cgi-bin/perl, I use the statement:

    <link href="html/base.css" rel="stylesheet" type="text/css">

    Since normally everything is relative to the base directory "/var/www" I
    would think that it should work but it does not.
    If I use the full path it cant find the file
    "/var/www/var/www/html/base.css" Which shows that it append the full path
    name to the base directory.

    How can I programmatically specify the path to my CSS sheets and for that
    matter my images when I use them?

    Thanks in advance
    Jim Rendant, Sep 30, 2003
    #1
    1. Advertising

  2. Jim Rendant wrote:
    > I am having a problem with programming in perl using paths to style
    > sheets and other static pages. I need a little clarification


    <snip>

    > <link href="html/base.css" rel="stylesheet" type="text/css">

    --------------^^^^^^^^^^^^^
    That shall be a URL, not a path on your file system. I would guess
    "/base.css" or whatever you would type in the location bar of your
    browser in order to read the style sheet.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Sep 30, 2003
    #2
    1. Advertising

  3. Jim Rendant

    m Guest

    Jim Rendant wrote:

    > <link href="html/base.css" rel="stylesheet" type="text/css">


    The problem may be that you're missing the correct address of
    the link, but maybe not:

    <link...> in generated pages doesn't always result in the link
    being loaded into the page by the browser. Try sucking the CSS file
    into a variable and writing it into the <head> of the HTML file between
    <style> tags.
    HTH
    m
    http://www.mbstevens.com/
    m, Oct 1, 2003
    #3
  4. m wrote:
    > <link...> in generated pages doesn't always result in the link
    > being loaded into the page by the browser.


    That has never happened to me. Can you give us an example that
    illustrates what you are saying?

    Of course, the CSS file must be located in a directory that is
    readable from the web. If it's not, it won't be loaded, but that would
    be the case both with a generated and a static page.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Oct 1, 2003
    #4
  5. Jim Rendant

    m Guest

    Gunnar Hjalmarsson wrote:
    > m wrote:
    >
    >> <link...> in generated pages doesn't always result in the link
    >> being loaded into the page by the browser.

    >
    >
    > That has never happened to me. Can you give us an example that
    > illustrates what you are saying?
    >
    > Of course, the CSS file must be located in a directory that is readable
    > from the web. If it's not, it won't be loaded, but that would be the
    > case both with a generated and a static page.


    Thanks for spurring me on to further testing of this, Gunnar.
    After running some tests over the past hour or so, I believe you
    are right. Don't know what I was doing wrong in my other programs,
    perhaps forgot to set the base address. At any rate, this promises to
    simplify a couple of my programs considerably.

    Cheers,
    m
    m, Oct 1, 2003
    #5
  6. Gunnar Hjalmarsson, Oct 1, 2003
    #6
    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. Bill Davis

    Question on perl/cgi paths

    Bill Davis, Jan 4, 2004, in forum: Perl
    Replies:
    5
    Views:
    681
    Bill Davis
    Jan 7, 2004
  2. Harry
    Replies:
    1
    Views:
    776
    Viator
    Dec 22, 2005
  3. Noah
    Replies:
    5
    Views:
    780
  4. paul
    Replies:
    4
    Views:
    278
    Michele Simionato
    Aug 3, 2003
  5. Ohad Lutzky

    Paths, gentleman, paths

    Ohad Lutzky, Nov 6, 2006, in forum: Ruby
    Replies:
    2
    Views:
    190
    David Vallner
    Nov 7, 2006
Loading...

Share This Page