Current location: Hot Scripts Forums » Programming Languages » Perl » Includes in Perl


Includes in Perl

Reply
  #1 (permalink)  
Old 06-12-03, 06:54 AM
digitalsea's Avatar
digitalsea digitalsea is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Includes in Perl

Hey everyone,

Is there a way to call another Perl script and have it displayed in a Perl script (sort of like how you can include a file in PHP)?

If you can't include another script to pull info from, is there another way to integrate the output from both scripts on one page?


This is something that has baffled me for hours!!!
__________________
- digitalsea
http://www.digital-sea.com/
Reply With Quote
  #2 (permalink)  
Old 06-12-03, 11:12 AM
Pearl's Avatar
Pearl Pearl is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Canada
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
It really depends on what exactly you are trying to do, and how your scripts are written. Perl Scripts can work together using for example the require(); method. But.. it's sort of hard to offer a suitable solution without some background on the scripts themselves. Are they completely independant scripts? Are "you" writing them so they work together? etc...

Perhaps someone has an idea, my coffee's still kicking in
http://www.perldoc.com/
http://www.perldoc.com/perl5.8.0/pod...Perl-Functions
Reply With Quote
  #3 (permalink)  
Old 06-12-03, 03:56 PM
digitalsea's Avatar
digitalsea digitalsea is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Well I actually want on my site...

http://www.digital-sea.com/

for a deatiled view of an app (such as (http://www.digital-sea.com/cgi-bin/detail.cgi?ID=4074) to able to also pull a live count of visitors on the site.

I was looking and found Perl scripts that did the counting, so wanted it to show up too on the page.
__________________
- digitalsea
http://www.digital-sea.com/
Reply With Quote
  #4 (permalink)  
Old 06-12-03, 07:33 PM
Pearl's Avatar
Pearl Pearl is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Canada
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
So.. did you just want a general visitor info on all your .cgi pages? or are you actually trying to do a visitor count per each detailed app page, such as: (4 users browsing Web Developer:Site Management etc..)

The second choice is yet harder to work out (more detailed), and unfortunately for the first choice I can't see any other way then hard coding your perl script to accept the other. Even more frustrating if both scripts aren't written by the same author.

It can be accomplished but without seeing the two scripts, I'd be mindlessly passing your through one example to the next :( Unless someone here has a quick dirty solution, and even then, without seeing the code... who knows. You can try the require(); method as I mentioned above and call the subroutine that outputs your visitor info where you want to see it, (just remember that the last statement must return true (1;) in the counter script you are calling), or simply write a small code that opens the database file where all your visitor info is being kept, whereas you could manipulate the output as well.

All the best!
Reply With Quote
  #5 (permalink)  
Old 06-12-03, 07:54 PM
digitalsea's Avatar
digitalsea digitalsea is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for your response.

I tried that and since the script is like the one here at hotscripts.com, I have to put the include in a file that would only parse the templates, so it doesn't directy effect the CGI script.

Would it be possible to use SSI only with the ID still in place...

for instance, the page would be detailed.shtml?ID=whatever

and 'whatever' would be replaced by the number which would replace the number in the SSI call itself? Can HTML do this kind of parsing?
__________________
- digitalsea
http://www.digital-sea.com/
Reply With Quote
  #6 (permalink)  
Old 06-12-03, 08:20 PM
Pearl's Avatar
Pearl Pearl is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Canada
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
But your app pages are generated through a .cgi script? or can you make, I assume (Links by Gossamer?) update your pages to produce static pages? If so then you can use SSI in your template design. You can't have SSI + CGI, it's one or the other, however there are some weird servers out there that let you parse SSI with CGI. Sorry you lost me on this one :\

and.. when you say you "tried that" what exactly did you try? require, or coding it in yourself? and if so what happened when you tried? Did you get an error?
Reply With Quote
  #7 (permalink)  
Old 06-13-03, 05:41 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
If you goto my website I have a perl counter on there. I use the vertual include to call the script and grab the output. I also had to rename the index.html to index.shtml. if you just put in this on the index.shtml file where I wanted the output;

<!--#include virtual="/cgi-bin/counter.pl" -->

Im only starting out in perl so I may have got the wrong end of the stick to what you were asking but hope its some use to you.
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #8 (permalink)  
Old 06-13-03, 08:10 AM
digitalsea's Avatar
digitalsea digitalsea is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Pearl,

I tried to insert basically the entire Perl script that counted visitors (only four lines - something I had from a couple years back) into the parsing script and even add.cgi itself, but without any luck. I use Links 2.0 and tried to look at the Gossamer Forums, but they don't really support it anymore...


My server does let me call a CGI with SSI, so that's why I was asking about just generating a .shtml page and then dynamically filling the ID with a form tag.

I know you can specify contents of a form (like a textfield) by using ?textfield=whatever, but could I use a hidden field in the SSI call to pull the correct ID?

If you're totally confused let me know...
__________________
- digitalsea
http://www.digital-sea.com/
Reply With Quote
  #9 (permalink)  
Old 06-13-03, 12:19 PM
Pearl's Avatar
Pearl Pearl is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Canada
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Oh yeah.. I'm totally confused! Happens often.. don't worry. Eventually I'll go "OH.. that's what you meant!"

Okay.. the reason I'm lost is because at first I thought you wanted to code in your counter and include it somehow on your scripts that you are already using. I think I'm realizing now that all you wish to do is try the SSI method. Is this right?

My server does let me call a CGI with SSI,
Firstly if your server requires you to change your extension to .shtml inorder for SSI to parse correctly on your pages, I'll bet to bottoms that you cannot parse SSI within a CGI script. Just a guess. Or else you could just easily insert your SSI tag within your generated header/footer file.

I'm not familar with the codings of Gossamer Links, so I'm not very helpful on that.. in fact I'm not being helpful at all, I feel like a dork 'cause I can't for the life of me see what you're doing.

generating a .shtml page and then dynamically filling the ID with a form tag.
Why do you want to do this? Curious. From what I can see you already have the ID number's filled in: ex: detail.cgi?ID=5038

I know you can specify contents of a form (like a textfield) by using ?textfield=whatever, but could I use a hidden field in the SSI call to pull the correct ID?
Under normal circumstances, there is a program at the other end that reads the output from the get/post (Query_String), that will manipulate what has been entered from let's say the textfield. SSI (Server Side Includes) is only a convenient method to insert things such as the time, files, or to execute a cgi program etc... where your server reads this information and if correct, it will insert whatever it is you're calling. Therefore, you can't input a hidden field (not that I know of) that will insert your new ID tag from SSI alone. However you could try to code a program that reads either the query string from your ID page that the SSI tag is inserted then manipulate the code to replace the SSI tag with whatever it is you want.

Now does that sound confusing. Just to reiterate.. all you want to do is put a counter on your cgi pages right?
Reply With Quote
  #10 (permalink)  
Old 06-13-03, 12:50 PM
digitalsea's Avatar
digitalsea digitalsea is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Yes!!

Basically I want to include a Perl program that counts current visitors on my detail (CGI) pages.

I though I could use SSI to call the counter and then the detailed page on the same document, like

<! include virtual "path to counter">
<! include virtual "path to detail.cgi?ID= (this is where the hidden form would go) ">

then when you went to detailed.shtml?ID=whatever it will fill in the ssi ID part.

I'm guess this is more trouble then it really is...
__________________
- digitalsea
http://www.digital-sea.com/
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl newbie has a problem... fowler23 Perl 4 03-24-10 05:14 PM
Perl CGI wrapper script available? paulbearer Script Requests 0 09-17-03 03:18 PM
Running Perl scripts under Microsoft IIS retrocom Perl 3 08-23-03 04:38 PM
Bookings/Availability PHP or Perl Script Mista Mike Script Requests 1 08-20-03 08:37 AM
Flatfile single Forum with Perl Gaz General HotScripts Site Discussion 1 08-07-03 04:37 AM


All times are GMT -5. The time now is 04:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.