www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Perl and data query

  1. #1
    Join Date
    Jun 2008
    Posts
    223

    resolved [RESOLVED] Perl and data query

    Hi, I don't know if what I would like to do is even possible.

    A Server Side Include (SSI) works fine on HTML pages, calling up a Perl script. However, they don't work from within a Perl script.

    For instance: an HTML file has an SSI to a script which reads a flat file database.
    Code:
    <!--#include virtual="/cgi-bin/someting/ascript.pl?action=read&data=file&id=1" -->
    (This is handled by a Query String with special parser in script)
    The field in the record that it is reading, cannot have another SSI.

    I wish it could (some serious wishful thinking here)

    Or is there another way?
    Like in the content of what is read, something could be entered in my editor that would invoke another script or sub routine or ?

    I have thought of JavaScript, which could be entered in my editor, but would rather keep away from that.

    Any Ideas?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,141
    It's certainly possible for a Perl script to call another Perl script that was originally designed to be accessed via SSI. The CPAN module LWP::UserAgent makes it pretty easy, and it's not outrageously difficult to parse out the <body> content of an HTML page. But it is more complicated to get two Perl scripts to work together than it is to simply insert a <!--#include--> command in an HTML file. Do you know Perl programming or are you using ready-made scripts?
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Jun 2008
    Posts
    223
    Hi Rick, I write my own (not perfect, but they work).

    Let's say ascript.pl reads in the FFDB from SSI in HTML File:
    Code:
    1|Calling script from data|Okay I have an entry and want to include something else from another script in the entry. How do I do that?<br><br><b>This is my B content</b><br><br><!--#include virtual="/cgi-bin/someting/bbb.pl" --><br><br>The C Content could say<br><br><!--#include virtual="/cgi-bin/someting/ccc.pl" --><br><br>So the actual SSIs are in the flat file database
    This returns:
    Calling script from data
    Okay I have an entry and want to include something else from another script in the entry. How do I do that?

    This is my B content

    The C Content could say:

    So the actual SSIs are in the flat file database
    I get the same with relative or full server path in the content SSI's. Both the little scripts just have a bit of text in for testing.

    See what I mean?

    PS
    Thinking about if further. Since I have already grabbed the field, it could be put in a hash and then a while loop looking for certain conditions (instead of the SSI - say **bbb**) and when the condition is met, a require for the bbb script is coded into the read portion of the main script or it returns empty. I'll see if that works.
    Last edited by edatz; 05-08-2012 at 03:51 AM.

  4. #4
    Join Date
    Jun 2008
    Posts
    223
    I'm going about this all wrong (that's me being half awake when I started)

    First off it has to be invisible, so a tag must be used.

    So - I have a block of text from my database and in it is a tag
    Code:
    Text text text text text text text text
    <bbb>
    More text more text more text more text more text more text
    
    .... so that it shows (including from the other sub routine) ....
    
    Text text text text text text text text
    
    Blah blah blah blah blah blah blah
    
    More text more text more text more text more text more text
    The object would be to replace that tag with a call to a sub routine which will have changeable content in it.

    The rest of the block of text will show as normal, with the sub call content in the middle of it

    Does that make more sense?

  5. #5
    Join Date
    Jun 2008
    Posts
    223
    I am getting somewhere on this....

    Code:
    @td = "$fd[2]";
    foreach $line (@td) {      
    print qq ~$line~;
    if ( ~ m/<bbb>/ ) {
    
    ## need to something more with this
    bbbbb();
    
    } else {print qq ~$line~;}
    }
    What happens is I see the results of the sub call, but after my block of text, instead of in the middle of it. I think something is needed in the if statement. Not sure how as this is new to me.

  6. #6
    Join Date
    Jun 2008
    Posts
    223
    I've scrapped the idea - it was just a side thought anyways.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles