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

Hi Monks!

I have a bunch of Perl scripts and html files that displays sequentially on the browser. But the way I am moving from page to page is by using REDIRECTS inside of each page. Its not efficient because adding pages in different order makes me go to all the other pages do change parameters for the REDIRECT.

My question is if someone would know a easier way of controlling these scripts to run sequentially from a fake cron job or some other main Perl program that would allow some kind of administration on these files, like allowing them to run and stop at specific times.

Thanks for the help and I hope I explained what I am trying to do well.

Thanks again!

Replies are listed 'Best First'.
Re: Controlling Running Perl Scripts
by suaveant (Parson) on Apr 25, 2007 at 14:55 UTC
    Well... without knowing much about your application a simple way to make it work would be to create a file that lists all the scripts that should run in which order, have each one open it, find itself in the list and run the successive one. This lets you make changes easily without totally revamping your system.

    That being said, sounds like you should totally revamp your system. :) I'm not sure what your doing but a bunch of successive redirects is seldom a pretty thing.

                    - Ant
                    - Some of my best work - (1 2 3)

Re: Controlling Running Perl Scripts
by Moron (Curate) on Apr 25, 2007 at 16:05 UTC
    maybe something like ...?
    our @sequence = ( "path1", "path2", # ... ); sub nextpath { for ( my $i=0; $i<=$#sequence; $i++ ) { ( $PATH_INFO eq $sequence[$i] ) or next; ( $i < $#sequence ) ? return( $sequence[$i+1]); : return( $sequence[0]); } undef(); }
    (updated with thx to shigetsu)
    __________________________________________________________________________________

    ^M Free your mind!

      There's a minor typo:
      our $sequence = ( "path1", "path2", # ... );
      should probably read
      our @sequence = ...
      instead.
        I am going to test with something like that!Thanks!
Re: Controlling Running Perl Scripts
by andye (Curate) on Apr 25, 2007 at 15:36 UTC
    You could change them so they run from the command line instead of as CGI scripts, then run each one as an actual cron job.

    There's a module Schedule::Cron that could be useful, if for some reason you can't use cron itself.

    HTH!

    Best wishes, andye