I was modifying Lincoln Stein's "CGI and frames" example script when I got bogged down with this bug. The script is below in its entirety. When it runs it loads the nav bar page in the topFrame (no problems there) and then loads mainFrame based on the parameter 'content'. This wasn't happeneing so I added "start" and "finish" print statements to the sub, and "start" got printed and that was it. So I added a if/else check to see if @bot_file (the product of a file slurp) was defined and that test never executes. I have been calling the script like so: http://www.thesite.com/cgi-bin/redirect.pl?content=/path/info/here/ and my "starting to open $content" appeared to have $content undef so I added
my $content = $q->param( 'content' ); if (!$content){ print $q->header,"no damn content"; exit; }
right under the $content variable assignment and the dang thing came back undef but what is more the script somehow printed the frameset and gave me the "no damn content" message in both frames!! I am so baffled. Any advice heartily welcomed!!
TIA
jg
edited by boo_radley : added readmore
#!/usr/local/bin/perl -w use strict; use CGI; my $q = new CGI; my $path_to_top = "/home/somesite/www/site/main_frame_top3.html"; my $content = $q->param( 'content' ); my $TITLE="Welcome to New Orleans"; my @top_file; my $script_name; my $path_info = $q->path_info; print $q->header; # If no path information is provided, then we create # a side-by-side frame set if (!$path_info) { &print_frameset; exit 0; } &print_html_header; &print_top if $path_info=~/top/; &print_mainframe if $path_info=~/main/; &print_end; # Create the frameset sub print_frameset { $script_name = $q->script_name; print <<EOF; <html><head><title>$TITLE</title></head> <frameset rows="147,*" frameborder="NO" border="0" framespacing="0" co +ls="*"> <frame src="$script_name/top" scrolling="NO" name="topFrame"> <frame src="$script_name/main" name="mainFrame"> </frameset> EOF ; exit 0; } sub print_html_header { print $q->start_html($TITLE); } sub print_end { print $q->end_html; } sub print_top { open (FH, "$path_to_top") or die "where's the damn file? : $!"; @top_file = <FH>; close FH; print @top_file; } sub print_mainframe { print "starting to open $content"; open (OH, "$content") or die "where's the damn file? : $!"; my @bot_file = <OH>; close OH; if (!@bot_file) { print "empty array! whassup wi'dat?"; exit; } else { print "the array is @bot_file!"; exit; } print @bot_file; print "finish"; }
_____________________________________________________
Think a race on a horse on a ball with a fish! TG

In reply to Why is this param undefined? and Why isn't exit stopping the script from running? by jerrygarciuh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.