We help IT Professionals succeed at work.

simple search .pl  question.

trudymaresch
trudymaresch asked
on
I am using a simple search .pl that returns the pages where items are located.  I am not too familiar with perl and not sure how to have it return the correct url.

Problem CGI bin is located in same directory level as "public", not in the public folder and admin wont relocate for me.  Files can only be found in public/whatever*.htm*, ... results returned show up like http://www.thesite.com/public/whatever.html
which isnt' the actual url - this is ...
http://www.thesite.com/whatever.html


How do I return only the URL less the word public.

Here is the print results sub:

_______________________________________________________

sub return_html {
   print "Content-type: text/html\n\n";
   print "html>\n head>\n  title>Results of Search/title>\n /head>\n";
   print "body bgcolor=ffffff>\n center>\n\n \n
\n
 /center>\n";
   print "font face=arial>Below are the results of your Search in no particular order:p>hr size=7 width=75%>p>\n";
   print "ul>\n";
   foreach $key (keys %include) {
      if ($include{$key} eq 'yes') {
         print "li>a href=\"$baseurl$key\">$titles{$key}/a>\n";
 
Comment
Watch Question

Commented:
Hi there,

Ok, if $baseurl contains the "http://www.thesite.com/" part
and the $key contains the incorrect "public/whatever.html" part

then one way you could do it is by inserting the following before the line

print "li>a href=\"$baseurl$key\">$titles{$key}/a>\n";


$the_href = $baseurl . $keys;
$the_href =~ s/thesite\.com\/public/thesite\.com\//i;

you'll just have to replace the name of your site the both times in the second line, and of course if your site is at a .co.uk or .org then you'll have to replace them as well
just make sure you remember that you'll have to escape periods or forward/backslashes with a backslash

and don't forget to change the line

print "li>a href=\"$baseurl$key\">$titles{$key}/a>\n";

to

print "li>a href=\"$the_href\">$titles{$key}/a>\n";

Author

Commented:
well I think some of this got lost in the cut & paste but I'm still looking at it.

Trudy
CERTIFIED EXPERT

Commented:
trudymaresch,

".... results returned show up like
http://www.thesite.com/public/whatever.html
which isnt' the actual url - this is ...
http://www.thesite.com/whatever.html


How do I return only the URL less the word public...."

Can you post the entire code here? Also can you post the exact URL of your site? I tried calling the URL that you posted earlier, & could not see anything?

Please provide as much more detail as you can.

This will help you get a more accurate answer, faster.

Author

Commented:
Hi, b13
I was correct the code somehow got cut up and pasted sorry,
However I was able to put it in the way it started out.

Just one small error ..

$the_href = $baseurl . $keys;

s/b $the_href = $baseurl . $key;

then it worked except that the URL shows with http://www.thesite.com//direct/whatever.html

an extra "/" in between the real directory and site name.

It doesn't affect IE5.0 but it may affect other browsers.
Commented:
Yeah, sorry about that, too many hours glaring at screens, but i'm sure you know the syndrome

$the_href =~ s/thesite\.com\/public/thesite\.com\//i;

s/b

$the_href =~ s/thesite\.com\/public\//thesite\.com\//i;

this should take care of the extra "/"

let me know if there is anything amis, again :)

is the "direct" part an issue at all

Author

Commented:
Thanks B__13... it seems to be working now.

What do you mean by
is the "direct" part an issue at all

Author

Commented:
My apologies, I thought I had accepted your answer already!!! Sorry, hope you can help me in future.

Trudy

Explore More ContentExplore courses, solutions, and other research materials related to this topic.