On Fri, Apr 19, 2002 at 08:50:04AM +0000, A Taylor wrote: > So if the result of the password check is False then i want to run a perl > script called 'password.pl'. If the password is true I want to run a script > called 'page.pl' (for example). But how do i tell perl to run 'password.pl' > or 'page.pl' ?????
The easiest way to call an external command is the 'system' function (perldoc -f system). There are other methods (perldoc perlipc), but that one should be sufficient for your needs. > I could write all these pages into one script and do a check that says if > password is True do this.... else do that ...... but there must be a way of > calling perl scripts external to the one that is running ??? Hmm, this sounds as if you have a. legacy code that has to be used or b. a design problem With very little effort, you can store the functionality of password.pl and page.pl in a Module and *use* that module. You have the source in an external file, so your main program doesn't get cluttered, but you now have internal access to your functions instead of relying to an external program where exchange of error messages and things like that are rather limited. If your sub programs are nicely written and don't make use of global variables, it should more or less be sufficient to do the following ---------- MyPass.pm ---------- package MyPass; # <-- Should be same as filename without .pm # INCLUDE your password.pl here 1; # <-- That's needed ---------- Password.pm ---------- *IF* your password.pl is written clean enough - no globals - the only change you should need to make is to wrap all the main program code in a function that you can call from your overlying program. You call that function by use MyPass; ... MyPass::MyMainFunction(...) as you can call all the other functions and (now module)global variables in your module file by prefixing them with "MyPass::". The same goes for your page.pl. The big advantage of this is "code reuse", since you can now use MyPass in other applications that use the functionality. That's the caveman approach to perl modules, but it should get you started. For further information read perldoc perlmod perldoc perlboot perldoc perltoot -- If we fail, we will lose the war. Michael Lamertz | +49 221 445420 / +49 171 6900 310 Nordstr. 49 | [EMAIL PROTECTED] 50733 Cologne | http://www.lamertz.net Germany | http://www.perl-ronin.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]