GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Perl include HELP! (https://gfy.com/showthread.php?t=358968)

archael 09-19-2004 06:40 PM

Perl include HELP!
 
Hey,
I'm running a script that gets a header, a body, and a footer and outputs it in a html file. The header and footer is the same for all but the body changes for each.

Each body is a perl search script and is different for all categories.
What I need is to know the code how to call and RUN a perl script from inside the other perl script and output that in the output file.

Can anyone help me out?

Thanks,
Jon

DimeStoreNovel 09-19-2004 06:56 PM

i have no clue

bump

help this guy will ya !!!!!!!!!!!!!!!!!!!!!!

TDJ 09-19-2004 07:01 PM

You can do this either of two ways. First way is to make the search program a package. Or, since you're talking about the search program just being a program unto itself, assuming it outputs via PRINT commands to STDOUT, you do:

my $searchresults = `/path/to/searchprogram.pl`;

print $header;
print $searchresults;
print $footer;

Anyways, that's the idea. I'd explain the package thing, but its a bit more complicated.

TDJ

archael 09-19-2004 07:14 PM

tried that but all it's doing is printing the path, it doesnt actually open the file. And the main part of my problem is not the fact that the file doesnt open.

I can open the file no problem but that is whats wrong. It is only outputting the code of the cgi script into the new html page.

What i need is for it to open while running the script so only the results are outputted to the final html file, not the code.

Anyone have any idea?

Thanks,
Jon

TDJ 09-19-2004 07:17 PM

you're using the wrong sign. One means system execute, the other means string of characters.

You want ` not ' - there is a big distinction. Its the one with the tilde on it.

Also, make sure the search script is executable:

chmod +x searchscript.pl

archael 09-19-2004 07:35 PM

ok got it to work, only problem now is that my counter doesnt seem to work well.

I need to have a </tr><tr> at the end of every 6 results.

When I ask to print $count, all the numbers come out correctly but when i do this:

if (int($thecount/6))

everything over 6 will have the </tr><tr>.

Any idea on this one?

Thanks,
Jon

archael 09-19-2004 08:54 PM

Well I was able to get it to work perfectly for one but I have 227 pages to get done. So now it looks like the script is timing out or something and its not creating anything. Heres what I have:

$body1 = `$pathof/search1.pl`;

$body2 = `$pathof/search2.pl`;

$body3 = `$pathof/search3.pl`;

down to 227, then I have this:

open(PAGE,">$pathoff/search1.html") or die "Writing Failed\n";
print PAGE "$html $body1 $htmlll\n";
close(PAGE);

open(PAGE,">$pathoff/search2.html") or die "Writing Failed\n";
print PAGE "$html $body2 $htmlll\n";
close(PAGE);

open(PAGE,">$pathoff/search3.html") or die "Writing Failed\n";
print PAGE "$html $body3 $htmlll\n";
close(PAGE);

Any faster way of getting this done so I dont have to put them all in different scripts?

Thanks,
Jon

By the way, $html and $htmlll are the header and footer but those work properly.

TDJ 09-20-2004 05:25 AM

Holy shit, you need some help with your programming I think :) You wasted a lot of time on that one. Watch this instead:

foreach my $num ( 1 .. 227 ) {
my $bodylink = "$pathof/search$num.pl";
my $body = `$bodylink`;
open(PAGE,">$pathoff/search$num.html") or die "blah";
print PAGE "$html $body $htmlll\n";
close(PAGE);
}

This will handle all 227 of them in just a few lines.

note replace haha123 with a left curly bracket.

:)

Pornweaver 09-20-2004 07:07 AM

What is "Perl"?

:1orglaugh


All times are GMT -7. The time now is 12:35 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123