Current location: Hot Scripts Forums » Programming Languages » Perl » Help on script, get file from different sub-folder


Help on script, get file from different sub-folder

Reply
  #1 (permalink)  
Old 09-12-11, 08:24 AM
fredfletcher fredfletcher is offline
New Member
 
Join Date: Sep 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Help on script, get file from different sub-folder

Hello,

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 "change-language.pl" - 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 part $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:

Code:
#!/usr/bin/perl
#
#
# 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?

}
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
file mailer script... lediscjockey Script Requests 8 07-10-08 04:50 AM
PHP script that knows to read csv file ELV1I2 Script Requests 5 08-05-07 03:19 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
Submit button....can it send info to my email w/out the use of php???? lisa33 HTML/XHTML/XML 7 10-17-06 11:46 AM
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 2 01-02-06 11:55 PM


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