Root wrote at Thu, 20 Jun 2002 14:04:30 +0200: > ok, found a solution to display the framessets > although it works just fine, I would really appreciate comments etc on how to >optimize the code :) > ... > my $path_info = $q->path_info; > > > if (!$path_info) { > &frameset; > exit 0; > } > } > if ($path_info =~/menu/) { > &menu; > }; > if ($path_info =~/top/) { > ⊤ > }; > if ($path_info =~/main/) { > &main; > };
Well, doesn't look very readable. There are thousands ways of calling a subroutine depending on a variable. Let's look at some: for ($q->path_info) { ! defined($_) && &frameset or /menu/ && &menu or /top/ && &top or /main/ && &main } Also a hash solution would be a good idea. BTW, why is it necessary to exit after the frameset. I'm afraid it's used to avoid a $path_info isn't defined warning. I think it won't be necessary so I removed it. In that special case, you want to call a subroutine with the same name as $path_info is. Here we could use perl's powerful dynamic referencing like with (untested) my $path_info = $q->path_info() || 'frameset'; { no strict 'subs'; &{$path_info} } (O.K., the security guys should include a $path_info =~ /frameset|menu|top|main/) > sub frameset { > > my $script_name = $q->script_name; > > print qq~ > <html> > <head></head> > <body> > <frameset rows="*" cols="206,*" > frameborder="yes" border="1" framespacing="0"> > <frame src="$script_name/menu" name="menu" > scrolling="NO" noresize id="left"> > <frameset rows="133,*" cols="*" > framespacing="0" frameborder="NO" border="0"> > <frame src="$script_name/top" > name="top" frameborder="yes" scrolling="auto" noresize bordercolor="#FF0000" >id="top"> > <frame >src="$script_name/main" name="main" id="main"> > </frameset> > </frameset> > <noframes><body> > Your browser does not display >frames.... get > a life and download a new browser....!! > </body></noframes> > <hr> > </body> Stupid question (I'm perl fan, not HTML fan): Shouldn't be the frameset definition between the header and the body. And there are two body tags, the first after the header, the second in the noframes part. (similar to </body>) > </html> > ~; > exit 0; Again, why to exit ? > } > } Cheerio, Janek PS: My browser doesn't display frames. Should I feel dead ? Normally I ignore pages telling me, that a shall use a new browser where I'm already using the quickest one. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]