CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Help on script, prepend?


New User

Sep 12, 2011, 5:43 AM

Post #1 of 1 (387 views)
Help on script, prepend? Can't Post


I'd really like some help on this, a PERL-CGI script (complete working script is below).

How can I add the server's root folder (folder_f) to this:

~ s/_e\.shtml/_f\.shtml/

This bit of code searches all occurences of _e.shtml and replaces them with _f.shtml (it being in the same folder).

Yet, in between that, I would like to be able to add the server's root of "folder_f" folder in there, or done another way if it has to.

My script is called "" - which has a hyperlink to it in "file_e.shtml". When clicked, it will try to find the file "file_f.shtml".

For example of what I would like it to do:

~ s/_e\.shtml/(FOLDER_F)_f\.shtml/ (found in script below, but I added (FOLDER_F_).

I tried: $calling_page =~ s/_e\.shtml/'s/^/$.\f'\/_f\.shtml/;

but it did not work. It brings me to the same _e.shtml file.

I would really appreciate anyone's help on this one, as I can't seem to get it right, with what I know so far.

The complete script is below, which works but only if both language files (file_e.shtml and file_f.shtml) reside in the same folder. I need to be able to have the script work, so that it will find the file (file_f.shtml) but in a different sub-folder on the server's root called "FOLDER_F" folder.

In the line $calling_page =~ s/_e\.shtml/_f\.shtml/; of the script, is there a way to do this:

$calling_page =~ s/_e\.shtml(FOLDER_F)/_f\.shtml/; - FOLDER_F being in parentheses is where I would like to be able to have the script modified so that it goes to a sub-folder and get file_f.shtml in FOLDER_F sub-folder.

What I have so far follows WORKS, but only works if both _e.shtml and _f.shtml files are in the same folder:

# get the URL for the Web page that called this script
$calling_page = $ENV{'HTTP_REFERER'};

if($calling_page =~ /(.*)\#.*/) {

# # only take the first part up to the #
$calling_page = $1;}

# ignore any file that is not _e.shtml or _f.shtml and do nothing!

# is this an _e.shtml file?

if($calling_page =~ /_e\.shtml/) {
# replace the suffix

$calling_page =~ s/_e\.shtml/_f\.shtml/;

print "Location: $calling_page\n\n";

# then is this an _f.shtml file?



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives