.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AutoRunmode::FileDelegate 3pm" .TH AutoRunmode::FileDelegate 3pm "2022-06-09" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Application::Plugin::AutoRunmode::FileDelegate \- delegate CGI::App run modes to a directory of files .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& # 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 \*(AqCGI::Application\*(Aq; \& 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 \& (\*(Aq/path/to/runmodes\*(Aq) \& $self\->param(\*(Aq::Plugin::AutoRunmode::delegate\*(Aq => $delegate); \& } \& \& # you now have two run modes \& # "my_run_mode" and "another_run_mode" .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Using this module, you can place the definition of your run modes for a CGI::Application into directory of files (as opposed to into a Perl module). .PP Each run mode is contained in its own file, named foo.pl for a run mode called foo. The run modes are lazily evaluated (on demand) for each request. In the case of mod_perl this means you can update them without restarting your web server. In the case of plain \s-1CGI\s0 it means a reduced startup cost if you have many run modes (because only the one that you need gets parsed and loaded, along with dependent modules). .SS "Using more than one directory with runmodes" .IX Subsection "Using more than one directory with runmodes" You can pass multiple directory paths to the constructor for the delegate: .PP .Vb 2 \& my $delegate = new CGI::Application::Plugin::AutoRunmode::FileDelegate \& (\*(Aq/path/to/runmodes\*(Aq, \*(Aq/path/to/more_runmodes\*(Aq) .Ve .PP In this case, they will be searched in order. The first matching file becomes the run mode. In the case of errors with that file, the module will croak (and not continue the search in the remaining directories). .SH "BUGS" .IX Header "BUGS" With all the namespace nesting going on the name of this module has reached an intolerable Java-esque length. .SH "SEE ALSO" .IX Header "SEE ALSO" If you like 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 \s-1HTML\s0 templates and the Perl code needed to provide them with data. .SH "AUTHOR" .IX Header "AUTHOR" Thilo Planz, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2005 by Thilo Planz .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.