Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to sort and how to show cgi output into an iframe?

Reply
Thread Tools

How to sort and how to show cgi output into an iframe?

 
 
V S Rawat
Guest
Posts: n/a
 
      10-06-2008
I have put a website search form on my home page. it has just a textarea
in which the term(s) to be searched are entered and then submit button
calls the perlscript that is finding that term in all files in the
website and showing the links of those files in which the term is
present. It is working correctly.

Two issues:

1. Perl is either checking files in the order of their filenames or in
the order in which it finds them in the folder, so the results are not
coming sorted. One menu branch items are coming scattered within other
menu branches items.

How can I sort it out so that at least one menu branch comes together?

2. The submit button is on the main home page.

all other links on the homepage are showing their results into an iframe
in the middle, using target="iframe"

but perl generated page comes standalone.

How can I show the results of this submit into the iframe?

thanks.
--
V
 
Reply With Quote
 
 
 
 
V S Rawat
Guest
Posts: n/a
 
      10-06-2008
On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:

> I have put a website search form on my home page. it has just a textarea
> in which the term(s) to be searched are entered and then submit button
> calls the perlscript that is finding that term in all files in the
> website and showing the links of those files in which the term is
> present. It is working correctly.
>
> Two issues:
>
> 1. Perl is either checking files in the order of their filenames or in
> the order in which it finds them in the folder, so the results are not
> coming sorted. One menu branch items are coming scattered within other
> menu branches items.
>
> How can I sort it out so that at least one menu branch comes together?
>
> 2. The submit button is on the main home page.
>
> all other links on the homepage are showing their results into an iframe
> in the middle, using target="iframe"
>
> but perl generated page comes standalone.
>
> How can I show the results of this submit into the iframe?
>
> thanks.



my gawd. So simple. And I spent so long thinking out what to do.

form target="iframe" shows the result of perl into iframe.

The company of this ng made me wise. thanks.
--

That sorting part is still holding me.

--
V
 
Reply With Quote
 
 
 
 
V S Rawat
Guest
Posts: n/a
 
      10-06-2008
On 10/7/2008 1:14 AM India Time, _V S Rawat_ wrote:

> On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:
>
>> I have put a website search form on my home page. it has just a textarea
>> in which the term(s) to be searched are entered and then submit button
>> calls the perlscript that is finding that term in all files in the
>> website and showing the links of those files in which the term is
>> present. It is working correctly.
>>
>> Two issues:
>>
>> 1. Perl is either checking files in the order of their filenames or in
>> the order in which it finds them in the folder, so the results are not
>> coming sorted. One menu branch items are coming scattered within other
>> menu branches items.
>>
>> How can I sort it out so that at least one menu branch comes together?
>>
>> 2. The submit button is on the main home page.
>>
>> all other links on the homepage are showing their results into an iframe
>> in the middle, using target="iframe"
>>
>> but perl generated page comes standalone.
>>
>> How can I show the results of this submit into the iframe?
>>
>> thanks.

>
>
> my gawd. So simple. And I spent so long thinking out what to do.
>
> form target="iframe" shows the result of perl into iframe.
>
> The company of this ng made me wise. thanks.
> --
>
> That sorting part is still holding me.
>


Further, how to find whether my server supports SSI or not?

to avoid generating entire html through perl, I have created an html
file of the header part that remains common across the perl script results.

I want to include it in my result and then add whatever perl generates
along with footer.

How to give that command in my perlscript?

I have added in my perlscript
print "<!--#include file=\"index_search_include.txt\"-->\n";
where index_search_include.txt is the header file that I have made.

but server is giving 500 internal server error and error logs are showing

malformed header from script. Bad header=<!--#include file="index_searc:
/home/username/public_html/cgi-bin/search.cgi

where to put that index_search_include.txt file? in cgi-bin or in
public_html or where, and what name to include? just the file name or
even the path /home/username/public_html/index_search_include.txt

there was also some issue that .html is to be renamed to .shtml for ssi
to work. I couldn't understand which .html file to rename.

if server doesn't support html, I would need to generate entire thing
line by line through perl or to read from that file and write thru perl.

Thanks.
--
V
 
Reply With Quote
 
smallpond
Guest
Posts: n/a
 
      10-06-2008
On Oct 6, 3:44 pm, V S Rawat <(E-Mail Removed)> wrote:
> On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:
>
>
>
> > I have put a website search form on my home page. it has just a textarea
> > in which the term(s) to be searched are entered and then submit button
> > calls the perlscript that is finding that term in all files in the
> > website and showing the links of those files in which the term is
> > present. It is working correctly.

>
> > Two issues:

>
> > 1. Perl is either checking files in the order of their filenames or in
> > the order in which it finds them in the folder, so the results are not
> > coming sorted. One menu branch items are coming scattered within other
> > menu branches items.

>
> > How can I sort it out so that at least one menu branch comes together?

>
> > 2. The submit button is on the main home page.

>
> > all other links on the homepage are showing their results into an iframe
> > in the middle, using target="iframe"

>
> > but perl generated page comes standalone.

>
> > How can I show the results of this submit into the iframe?

>
> > thanks.

>
> my gawd. So simple. And I spent so long thinking out what to do.
>
> form target="iframe" shows the result of perl into iframe.
>
> The company of this ng made me wise. thanks.
> --
>
> That sorting part is still holding me.
>
> --
> V


You are getting the files in the order in which they appear in
the directory. To sort them:

1. read all the filenames into an array @filenames
2. to send the output to your page, loop thru the array using foreach
foreach (sort {$a cmp $b} @filenames)
3. to modify the order of the output, change {$a cmp $b} to a
different function.

To put all of the subdirectories first, for example, you will want to
test using '-d' and change the result of the comparison accordingly.

--S
 
Reply With Quote
 
V S Rawat
Guest
Posts: n/a
 
      10-06-2008
On 10/7/2008 1:58 AM India Time, _V S Rawat_ wrote:

> On 10/7/2008 1:14 AM India Time, _V S Rawat_ wrote:
>
>> On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:
>>
>>> I have put a website search form on my home page. it has just a textarea
>>> in which the term(s) to be searched are entered and then submit button
>>> calls the perlscript that is finding that term in all files in the
>>> website and showing the links of those files in which the term is
>>> present. It is working correctly.
>>>
>>> Two issues:
>>>
>>> 1. Perl is either checking files in the order of their filenames or in
>>> the order in which it finds them in the folder, so the results are not
>>> coming sorted. One menu branch items are coming scattered within other
>>> menu branches items.
>>>
>>> How can I sort it out so that at least one menu branch comes together?
>>>
>>> 2. The submit button is on the main home page.
>>>
>>> all other links on the homepage are showing their results into an iframe
>>> in the middle, using target="iframe"
>>>
>>> but perl generated page comes standalone.
>>>
>>> How can I show the results of this submit into the iframe?
>>>
>>> thanks.

>>
>> my gawd. So simple. And I spent so long thinking out what to do.
>>
>> form target="iframe" shows the result of perl into iframe.
>>
>> The company of this ng made me wise. thanks.
>> --
>>
>> That sorting part is still holding me.
>>

>
> Further, how to find whether my server supports SSI or not?


ok, when I upload the following in a file to my server, and open in
browser, I do see Monday. that means SSI is working for me. but not in
html file. it worked in shtml file.

<HTML>
<TITLE>Test File</TITLE>

<!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->

</HTML>

--

good enough. Now, the remaining parts are to be attended.

>
> to avoid generating entire html through perl, I have created an html
> file of the header part that remains common across the perl script results.
>
> I want to include it in my result and then add whatever perl generates
> along with footer.
>
> How to give that command in my perlscript?
>
> I have added in my perlscript
> print "<!--#include file=\"index_search_include.txt\"-->\n";
> where index_search_include.txt is the header file that I have made.
>
> but server is giving 500 internal server error and error logs are showing
>
> malformed header from script. Bad header=<!--#include file="index_searc:
> /home/username/public_html/cgi-bin/search.cgi
>
> where to put that index_search_include.txt file? in cgi-bin or in
> public_html or where, and what name to include? just the file name or
> even the path /home/username/public_html/index_search_include.txt
>
> there was also some issue that .html is to be renamed to .shtml for ssi
> to work. I couldn't understand which .html file to rename.
>
> if server doesn't support html, I would need to generate entire thing
> line by line through perl or to read from that file and write thru perl.
>
> Thanks.


 
Reply With Quote
 
sln@netherlands.com
Guest
Posts: n/a
 
      10-06-2008
On Tue, 07 Oct 2008 01:58:15 +0530, V S Rawat <(E-Mail Removed)> wrote:

>On 10/7/2008 1:14 AM India Time, _V S Rawat_ wrote:
>
>> On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:
>>
>>> I have put a website search form on my home page. it has just a textarea
>>> in which the term(s) to be searched are entered and then submit button
>>> calls the perlscript that is finding that term in all files in the
>>> website and showing the links of those files in which the term is
>>> present. It is working correctly.
>>>
>>> Two issues:
>>>
>>> 1. Perl is either checking files in the order of their filenames or in
>>> the order in which it finds them in the folder, so the results are not
>>> coming sorted. One menu branch items are coming scattered within other
>>> menu branches items.
>>>
>>> How can I sort it out so that at least one menu branch comes together?
>>>
>>> 2. The submit button is on the main home page.
>>>
>>> all other links on the homepage are showing their results into an iframe
>>> in the middle, using target="iframe"
>>>
>>> but perl generated page comes standalone.
>>>
>>> How can I show the results of this submit into the iframe?
>>>
>>> thanks.

>>
>>
>> my gawd. So simple. And I spent so long thinking out what to do.
>>
>> form target="iframe" shows the result of perl into iframe.
>>
>> The company of this ng made me wise. thanks.
>> --
>>
>> That sorting part is still holding me.
>>

>
>Further, how to find whether my server supports SSI or not?
>
>to avoid generating entire html through perl, I have created an html
>file of the header part that remains common across the perl script results.
>
>I want to include it in my result and then add whatever perl generates
>along with footer.
>
>How to give that command in my perlscript?
>
>I have added in my perlscript
>print "<!--#include file=\"index_search_include.txt\"-->\n";
>where index_search_include.txt is the header file that I have made.
>
>but server is giving 500 internal server error and error logs are showing
>
>malformed header from script. Bad header=<!--#include file="index_searc:
>/home/username/public_html/cgi-bin/search.cgi
>
>where to put that index_search_include.txt file? in cgi-bin or in
>public_html or where, and what name to include? just the file name or
>even the path /home/username/public_html/index_search_include.txt
>


If you generate, or get some portion of your html with perl, then pass
it on, you can do any sort of amalgomation you wan't.

It seams as though you are forcing the html through a processor that
won't take incomplete html.

You many need a perl script that joins html fragments into a whole
before sending it to the renderer.

You can do it one of two ways, insert the placeholder in the constant html
or insert it into the dynamic part, substitute, then send it to the renderer.

This avoids generating html because you are using constant html as the substitute,
and just printing out the joined parts. Since this is by design, there should be no
errors as long as the reconstituted whole does not have errors (which can be checked
before the renderer gets it).

This can be done by hand like mail merge substitution or you can use a reliable
capture parser (or do it all in ASP?):

=========================
use strict;
use warnings;

use RXParse; # VERSIN 2

my $p = new RXParse();
$p->setMode( 'html' => 1, 'resume_onerror'=> 1 );
$p->setHandlers('start' => \&starth, 'end' => \&endh);

sub starth
{
my ($obj, $el, $term, @attr) = @_;
my $buffer = lc($el);
if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
{
$obj->CaptureOn( $buffer );
}
}
sub endh
{
my ($obj, $el, $term) = @_;
my $buffer = lc($el);
if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
{
$obj->CaptureOff( $buffer, 1 );
}
}

open my $fh, 'c:\temp\header_footr.html' or die "can't open header_footr.html...";

$p->CaptureOn('ALL');
$p->parse($fh);
$p->CaptureOff('ALL');

close $fh;

$p->DumpCaptureBuffs();

# generate dynamic html
# ...

# substitute the capture sequence body for the dynamic html generated.
# the sequence is just the index into the main capture array.
# this is all 'raw' html. functions are provided for this though.
# ....

# write/send out the entire sequence now as complete html
# ...



__END__



BUFFER: all
=====================================
index seqence
----- --------
[0] 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>CNN.com - Breaking News, U.S., World, Weather,
Entertainment & Video News</title>
<meta http-equiv="refresh" content="1800;url=?refresh=1">
<meta name="Description" content="CNN.com delivers the latest breaking news and information on the latest top stories, weather, business, entertainment, politics, and more. For in-depth coverage,
CNN.com provides special reports, video, audio, photo galleries, and interactive guides.">
<meta name="Keywords" content="CNN, CNN news, CNN.com, CNN TV, news, news online, breaking news, U.S. news, world news, weather, business, CNN Money, sports, politics, law, technology, entertainment,
education, travel, health, special reports, autos, developing story, news video, CNN Intl">
</head>
[1] -2
[2] 3 undefined
[3] -4
[4] 5 </html>


BUFFER: substitutebody
=====================================
index seqence
----- --------
[0] 2 <substitutebody DROP YOUR BODY IN THIS SEQUENCE></substitutebody>


BUFFER: substitutefooter
=====================================
index seqence
----- --------
[0] 4 <substitutefooter DROP YOUR FOOTER IN THIS SEQUENCE></substitutefooter>

 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      10-06-2008
V S Rawat <(E-Mail Removed)> wrote:

>Two issues:
>1. Perl is either checking files in the order of their filenames or in
>the order in which it finds them in the folder, so the results are not
>coming sorted.


Perl simply uses whatever the operating system returns. If the OS
returns them in random sequence, then Perl will just use that sequence.

>How can I sort it out so that at least one menu branch comes together?


If you want file names to be sorted by some criteria, then you need to
sort them yourself. See "perldoc -f sort".

jue
 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to convert exe file of cgi script into .cgi extension. Muzammil C++ 1 08-28-2008 07:50 PM
Merge Sort in C - array output is same as input after sort routine completes rkk C Programming 9 09-24-2006 08:30 PM
I need some help with browser output in ruby cgi - cgi.rb Professor Chen Ruby 0 02-06-2006 07:08 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments