http://www.perlmonks.org?node_id=344925

markmoon has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently working on a script that replaces about 40 HTML files to generate a portfolio section of an older website. I thought I was nearing completion because it works (or at least does what I was waiving dead chickens for ;-). However, when I starting checking it with different browsers to see how badly the CSS gets mangled, I realized that some of the browsers are doing something strange with the parameters. Instead of passing my values back to the script they seem to be simply trying to pass them to the directory the script is in (cgi-bin).

For example Mozilla 1.5, Safari 1.0.2 and I.E. 5.2 all properly send the parameters back to the calling script. Opera 6.03 and Netscape 4.77 both omit the script name but contain the rest of the path info. These are all on Mac OS X. The parameters are in the form of ?preview=deck or ?section=deck&image=deck1.jpg. The server is Red Hat running Apache 2.0.40.

I've looked through Super Search, categorized Q&A and the CGI Tutorials but can't find a similar problem. I'm not sure if this is a browser problem or have I done something odd?

Here's the script, although I don't think I'm doing anything weird...(I hope the readmore tags work)

#!/usr/bin/perl -wT use strict; use CGI qw/:standard :html3/; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; my $ROOT = "/path/to/files"; # figure out where to go if (param()){ ### Ho +uston we have input!!! ### if (param('preview')){ ### de +cide which section to preview my $section = param('preview'); create_links($section); }elsif (param('closeup')){ ### sh +ow closeup image ### my $section = param('closeup'); my $image = param('image'); my @closeup_info = ($section,$image); show_closeup(@closeup_info); }else{ die "I'm sorry, but that is not a valid selection.\n"; } }else{ ### script being called for first time -- show portfolio s +ections ### print_header(); portfolio_main(); the_end(); } #-------------------------------SUBROUTINES -------------------------- +-------------------------------------# # portfolio main displays the different portfolio section choices sub portfolio_main{ ### PRINT PORTFOLIO BANNER ### print div("<img src = \"/path/to/banner/portfol.gif\" class =\ +"banner\">"); print "\n"; my $class = "class = \"preview\""; print_nav(); ### PRINT MAIN PORTFOLIO SECTION PREVIEW IMAGES ### print div("<a href = \"?preview=deck\"> <img src = \"/path/to/ +images/deck/prevs/prevdeck7.jpg\" class =\"prev1\" id = $ print div("<a href = \"?preview=fence\"><img src = \"/path/to/ +images/fence/prevs/prevfence1.jpg\" class =\"prev1\" id = $ print div("<a href = \"?preview=bench\"><img src = \"/path/to/ +images/bench/prevs/prevbench1.jpg\" class =\"prev2\" id = $ print div("<a href = \"?preview=arb\"> <img src = \"/path/to/ +images/arb/prevs/prevarb3.jpg\" class =\"prev2\" id = $ } ### SHOW SELECTED SECTION PREVIEWS ### # $section which section (duh) i.e. decks, fences etc. # $path tells where to find preview image i.e. "\"/path/to/images/pre +vs/$section$num.jpg" sub create_links{ ### receives contents of param('preview') ex. +deck, fence, bench or arb ### my $section = shift; my $path = "/path/to/images/$section/prevs/"; my $dir_path = "$ROOT/path/to/images/$section/prevs/"; ### Open and read in the contents of the selected section's preview di +rectory ### opendir(DIR,$dir_path) or die "$!\n"; my @images; while (my $filename = readdir(DIR)) { push(@images,$filename) if ($filename =~ /$section\d+\.jpg/); } closedir(DIR); ### Create the page ### print_header(); print_banner($section); my $class = 1; my $id = 1; foreach my $image (@images){ my $preview = "\"$path$image\" class = \"prev$class\" id = \"p +$id\""; $image =~ s/prev//; print div("<a href = \"?closeup=$section&image=$image\"><img s +rc = $preview></a>"); print "\n"; $id++; if ($id > 4){ $class++; $id = 1; } } the_end(); } sub show_closeup{ ### receives $section and $image ### my $section = shift; my $image = shift; my $link_path = "/path/to/images/$section/"; print_header(); print_banner($section); print div("<img src = \"$link_path$image\" class = \"closeup\" +>"); print "\n"; the_end(); } sub print_nav { my $image_path = "/path/to/images"; print div({-class => 'buta'}, "<img src =\"$image_path/a1.gif +\">"),"\n"; print div({-class => 'buts'}, "<img src =\"$image_path/s1.gif +\">"),"\n"; print div({-class => 'butp'}, "<img src =\"$image_path/p1.gif +\">"),"\n"; print div({-class => 'butmid'},"<img src =\"$image_path/mid.gi +f\">"),"\n"; print div({-class => 'butr'}, "<img src =\"$image_path/r1.gif +\">"),"\n"; print div({-class => 'butm'}, "<img src =\"$image_path/m1.gif +\">"),"\n"; print div({-class => 'buty'}, "<img src =\"$image_path/y1.gif +\">"),"\n"; } sub print_header { print header(),"\n", start_html( -title => 'some site', -style => {-src => 'http://www.site.com/site +.css'}),"\n", } sub print_banner { my $section = shift; print div("<img src = \"/path/to/images/$section/ban$section. +gif\" class = \"banner\">"); print "\n"; } sub print_footer{ print div("footer info"),"\n"; } sub the_end{ # print_footer(); print end_html; }
--

Thanks,
markmoon

update: removed a line I forgot to comment out - doesn't affect the script though