0

Hello, I have a question.

I found a script on the Internet that lets people change from one language to another, in this case from English to French, but files must all reside in the same folder.

The script works, however, my files are in seperate folders in the root, being /e/ and /f/ respectively.

How can I implement a folder change with the corresponding filename of _e.shtml to _f.shtml ?

Here is the script in question which I tried to modify, but did not work:

# START Perl script

# get the URL for the Web page that called this script
$calling_page = $ENV{'HTTP_REFERER'};
# when the browser is Netscape, the referrer can contain the # and anchor name: REMOVE IT! (eg. http://clf-nsi/w3c.htm#clf)

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 -eng.htm 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?

} elsif($calling_page =~ /_f\.shtml/) {
    # replace the suffix
    $calling_page =~ s/_f\.shtml/_e\.shtml/;
    print "Location: $calling_page\n\n";}

# END Perl script

Thank you.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by wickedxter
0
# START Perl script

# get the URL for the Web page that called this script
$calling_page = $ENV{'HTTP_REFERER'};
# when the browser is Netscape, the referrer can contain the # and anchor name: REMOVE IT! (eg. http://clf-nsi/w3c.htm#clf)

if($calling_page =~ /\(/\w\/)index\.shtml/) {
    # 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 -eng.htm file?

if($calling_page =~ /\/e\/index\.shtml/) {
    # replace the suffix
    $calling_page =~ s/\/e\/index\.shtml/\/f\/index\.shtml/;
    print "Location: $calling_page\n\n";

# then is this an _f.shtml file?

} elsif($calling_page =~ /\/f\/index\.shtml/) {
    # replace the suffix
    $calling_page =~ s/\/f\/index\.shtml/\/e\/index\.shtml/;
    print "Location: $calling_page\n\n";}

# END Perl script

untested

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.