I've got the task to change all the small CGIs to have a logo on top of the site. To edit all that scripts is against Laziness, so i thought about a different approach - using frames. I build this small and simple wrapper. If it is called with a parameter 'app' it outputs the right CGI as part of a frameset and the browser does the job. In fact this just works 'cause all CGIs are called from only one page.
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw ( fatalsToBrowser ); use HTML::Template; my $q = new CGI; my $app = $q->param('app') || 'help'; my $template = HTML::Template->new(filename => 'app_wrap.tmpl'); my $application_to_call = '/main.html'; $application_to_call = '/cgi-bin/staff.pl' if ($app eq 'staff'); $application_to_call = '/db/staff/selstad.pl' if ($app eq 'adm_sta +ff'); $application_to_call = '/db/staff/birthday.pl' if ($app eq 'birthd +ay'); $application_to_call = '/db/staff/firmenjub.pl' if ($app eq 'jubilee') +; $application_to_call = '/db/staff/location.pl' if ($app eq 'locati +on'); print $q->header(); $template->param(app => $application_to_call); print $template->output(); exit;
and a html-template snippet:
<!-- snip --> <frameset frameborder="no" framespacing="0" border="0" rows="80,*"> <frame marginwidth="0" marginheight="0" scrolling="no" src="/logo_t +op.html"> <frame name="main" src="<TMPL_VAR NAME="app">"> </frameset> <!-- snip -->

Replies are listed 'Best First'.
Re: How to get those CGIs running in a frame.
by Tomte (Priest) on Apr 08, 2004 at 16:06 UTC

    you should consider a dispatch-table/-hash to do the dirty work done via if-statements: (the seclev stuff is only there to show some further benefits beneath readabilty-enhancement :)

    my $apps = { help => { app => '/main.html', seclev => 0, }, staff => { app => '/cgi-bin/staff' seclevel => 0, }, adm_staff => { app => '/db/staff/selstad.pl', seclevel => 10, }, birthday => { app => '/db/staff/birthday.pl', seclevel => 10, }, jubilee => { app => '/db/staff/firmenjub.pl', seclevel => 10, }, location => { app => '/db/staff/location.pl', seclevel => 10, }, }; my $app = $q->param('app'); $app = 'help' unless exists($apps->{$app}); my $application_to_call = $apps->{$app}{app};

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

      That's a nice idea.
      Thank you!

        That's a nice idea.
        Thank you!

        not mine ;-), I like to hand on your thanks to all the it-professionals sharing knowlegde and code in free spirit, leaving it for us to find...

        I leave out more sentimental sermon-like stuff;

        your most welcome :D

        regards,
        tomte


        Hlade's Law:

        If you have a difficult task, give it to a lazy person --
        they will find an easier way to do it.