in reply to Best way to call another perl file

Thanks for all the input so far. I thought about using modules, but I'd need a separate module for each, and so thought that that wouldn't be any more efficient. The file names of the secondary scripts would be stored in a database, with different ones being called on each run of the main script, based on user input. Should I still do that with modules?
Adding each as a different sub in the same module sounds like far more of a maintenance nightmare long term, as a new file/database entry will likely be added every several months. Tell me if your experience differs, but adding a new file and database entry sounds more maintainable in the long run.
Edit: To explain further, each of the called scripts is associated with a single PDF, filling it out according to info in the database. Each PDF is different enough to need its own logic on what goes where, thus its own script. If this is a dumb way of doing this, I would LOVE a better suggestion, as I don't really like this solution, but know it will work.

Replies are listed 'Best First'.
Re^2: Best way to call another perl file
by Anonymous Monk on Apr 02, 2015 at 20:22 UTC

    Vague talk is vague and not examples

    You don't need to stuff everything into one file

    Here are commands Stucki::Command::Ro Stucki::Command::Sham Stucki::Command::Bo, they correspond to lib/Stucki/Command/Ro.pm

    package Stucki::Command::Ro ; sub run { print "Ro ro ro-sham-bo, gently down the stream\n" } 1;

    They're loaded by by this module

    package Stucki; use Module::Load qw/ load /; sub run { my( $shelf, $command, @rest ) = @_; my $plugin = "Stucki::Command::".$command; load $plugin; ## or dies $plugin->run( @rest ); } 1;

    So from commandline you might use ./stucki ro ast some mo corn where stucki might be

    #!/usr/bin/perl -- use Stucki::Frontend::CLI; Stucki::Frontend::CLI->run;

    And a stucki.cgi might be

    #!/usr/bin/perl -- use Stucki::Frontend::CGI; Stucki::Frontend::CGI->run;

    And so on and so forth...

    Some examples of organizing such an "app": Ask, P5U, CPANPLUS/ CPANPLUS::Shell::Default / CPANPLUS::Shell::Tk / CPANPLUS::Shell::Wx
    App-Cme-1.002 Check or edit configuration data with Config::Model
    Config-Model-2.068 Create tools to validate, migrate and edit configuration files
    Config-Model-Approx-1.009 Approx configuration file editor
    Config-Model-Backend-Augeas-0.118 Read and write configuration data through Augeas
    Config-Model-CursesUI-1.104 Curses interface to edit config data through Config::Model
    Config-Model-Itself-1.243 Model editor for Config::Model
    Config-Model-LcdProc-2.042 Edit and validate LcdProc configuration file
    Config-Model-OpenSsh-1.236 OpenSSH config editor
    Config-Model-Tester-2.050 Test framework for Config::Model
    Config-Model-TkUI-1.345 Tk GUI to edit config data through Config::Model
    Config-Model-Xorg-1.106 Xorg configuration editor and validator

    cpan2pkg generating native linux packages from cpan
    App::CPAN2Pkg generating native linux packages from cpan
    App::CPAN2Pkg::Controller controller for cpan2pkg interface
    App::CPAN2Pkg::Lock Simple locking mechanism within cpan2pkg
    App::CPAN2Pkg::Module poe session to drive a module packaging
    App::CPAN2Pkg::Repository repository details for a given module
    App::CPAN2Pkg::Types types used in the distribution
    App::CPAN2Pkg::UI::Text text interface for cpan2pkg
    App::CPAN2Pkg::UI::Tk main cpan2pkg window
    App::CPAN2Pkg::Utils various utilities for cpan2pkg
    App::CPAN2Pkg::Worker poe session to drive a module packaging
    App::CPAN2Pkg::Worker::Mageia worker dedicated to Mageia distribution
    App::CPAN2Pkg::Worker::RPM worker specialized in rpm distributions

    math-image display some mathematical images App::MathImage math-image application module App::MathImage::Gtk2::AboutDialog App::MathImage::Wx::Main math-image wxWidgets main window App::MathImage::Tk::Main App::MathImage::Prima::Main

    more examples at Re: Recommendations for adding plugin/addon capability to a program and other places

      This is perfect. Thank you!