AutoRu...elegate(3pm)
β¨ NAME β¨
CGI::Application::Plugin::AutoRunmode::FileDelegate β bestie, it delegates your CGI::App run modes to a whole directory of files π
π SYNOPSIS π
# in file runmodes/my_run_mode.pl
sub {
my ($app, $delegate) = @_;
# do something here
};
# in file runmodes/another_run_mode.pl
sub {
# do something else
};
package MyApp;
use base 'CGI::Application';
use CGI::Application::Plugin::AutoRunmode
qw [ cgiapp_prerun];
use CGI::Application::Plugin::AutoRunmode::FileDelegate();
sub setup{
my ($self) = @_;
my $delegate = new CGI::Application::Plugin::AutoRunmode::FileDelegate
('/path/to/runmodes')
$self->param('::Plugin::AutoRunmode::delegate' => $delegate);
}
# you now have two run modes
# "my_run_mode" and "another_run_mode"
πΈ DESCRIPTION πΈ
okay so picture this: instead of shoving all your run mode definitions into a Perl module, you can justβ¦ put them in a directory of files. That's the whole thing. That's the vibe. π¦
Every run mode gets its own little home, and that file is named foo.pl for a run mode called foo. And here's the slay part β the run modes are lazily evaluated (on demand) for each request. What does that mean for you, bestie?
- Under
mod_perl? You can update them without restarting your web server. No cap. π₯ - Under plain CGI? You get a reduced startup cost if you have a ton of run modes, because only the one you actually need gets parsed and loaded, along with dependent modules. It's giving efficiency. β¨
π Using more than one directory with runmodes
You can pass multiple directory paths to the constructor for the delegate:
my $delegate = new CGI::Application::Plugin::AutoRunmode::FileDelegate
('/path/to/runmodes', '/path/to/more_runmodes')
In this case, they will be searched in order. The first matching file becomes the run mode. And if there are errors with that file? The module will croak β and it will not continue the search in the remaining directories. So like, it commits to its choice, periodt. π
π BUGS π
With all the namespace nesting going on, the name of this module has reached an intolerable Java-esque length. π that's it. that's the bug.
π«Ά SEE ALSO π«Ά
If you're obsessed with the idea of moving everything outside of Perl modules into separate files, you should also have a look at CGI::Application::Plugin::TemplateRunner, which does a similar thing for HTML templates and the Perl code needed to provide them with data. iykyk π
π AUTHOR π
Thilo Planz, <thilo@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright 2005 by Thilo Planz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie, no notes π
this was perl v5.34.0, dated 2022-06-09 β part of the User Contributed Perl Documentation, aka AutoRu...elegate(3pm) π go forth and delegate, you absolute icon πΈβ¨
π¦ where this page comes from
- debian bookworm: libcgi-application-plugin-autorunmode-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcgi-application-plugin-autorunmode-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcgi-application-plugin-autorunmode-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-application-plugin-autorunmode-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-application-plugin-autorunmode-perl 0.18-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms