### Quick Start Example Source: https://metacpan.org/dist/AI-Anthropic/view/README.md Minimal example to initialize the client and send a simple message. ```perl use AI::Anthropic;my $claude = AI::Anthropic->new( api_key => 'sk-ant-api03-your-key-here',);print $claude->message("Hello!"); ``` -------------------------------- ### Start the OTLP collector example Source: https://metacpan.org/dist/OpenTelemetry/view/lib/OpenTelemetry/Guides/Exporters.pod Clone the example repository and start the collector stack using docker-compose. ```bash git clone https://github.com/jjatria/perl-opentelemetry cd perl-opentelemetry/examples/collector docker compose up ``` -------------------------------- ### Implement setup() method Source: https://metacpan.org/pod/CGI%3A%3AApplication Example implementation of the setup() method to configure application parameters and run modes. ```perl sub setup { my $self = shift; $self->tmpl_path('/path/to/my/templates/'); $self->start_mode('putform'); $self->error_mode('my_error_rm'); $self->run_modes({ 'putform' => 'my_putform_func', 'postdata' => 'my_data_func' }); $self->param('myprop1'); $self->param('myprop2', 'prop2value'); $self->param('myprop3', ['p3v1', 'p3v2', 'p3v3']);} ``` -------------------------------- ### Quick Start Application Setup Source: https://metacpan.org/dist/Mojolicious-Plugin-Fondation-Setup/view/README.md Commands to initialize a new application directory, configure the application, and start the development server. ```bash # 1. Create a new application directory mkdir Myapp && cd Myapp # 2. Create myapp.pl echo 'use Mojolicious::Lite; use lib 'lib'; plugin "Config"; plugin "Fondation"; app->start;' > myapp.pl # 2. Create myapp.conf { Fondation => { dependencies => [ 'Fondation::Setup', ] }, } # 3. Initialize (creates assets, etc.) perl myapp.pl fondation init # 4. Start the development server perl myapp.pl daemon # 5. Open http://localhost:3000/setup in your browser ``` -------------------------------- ### Application Configuration Example Source: https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AFondation%3A%3ASetup Example of the configuration file generated by the setup wizard in the application home directory. ```perl { Fondation => { dependencies => ['Fondation::Model::DBIx::Async', 'Fondation::User'], }, 'Fondation::Model::DBIx::Async' => { backends => [main => { dsn => 'dbi:SQLite:dbname=data/app.db' }], },} ``` -------------------------------- ### Install modules and distributions Source: https://metacpan.org/pod/CPAN Examples of installing modules or distributions using direct names, file paths, or regular expressions. ```text install Dummy::Perl # installs the moduleinstall AUXXX/Dummy-Perl-3.14.tar.gz # installs that distributioninstall /Dummy-Perl-3.14/ # same if the regexp is unambiguous ``` -------------------------------- ### Getting Started with Minilla Source: https://metacpan.org/pod/Minilla Workflow for installing Minilla, creating a new distribution, and performing an initial release. ```bash # First time only % cpanm --with-recommends Minilla # Minilla has only a few deps. It should be very quick # Make a new distribution % minil new Dist-Name % cd Dist-Name/ # Git commit % git commit -m "initial commit" # Hack your code! % $EDITOR lib/Dist/Name.pm t/dist-name.t cpanfile # Done? Test and release it! % minil release ``` -------------------------------- ### GET /setup Source: https://metacpan.org/dist/Mojolicious-Plugin-Fondation-Setup/view/README.md Access the main page of the setup wizard. ```APIDOC ## GET /setup ### Description Displays the main page of the Fondation setup wizard. ### Method GET ### Endpoint /setup ``` -------------------------------- ### Run pad commands Source: https://metacpan.org/dist/PAD/view/script/pad Examples of starting the HTTP server with different configurations. ```bash # run HTTP server that serves current directory pad # Static # enable PAD::Plugin::Markdown pad Markdown # listen on different port pad Static --port 8080 ``` -------------------------------- ### Example path for libperl.so Source: https://metacpan.org/release/PEVANS/perl-5.45.1/view/Porting/pumpkin.pod Shows a typical directory structure for the architecture-specific libperl.so installation. ```text /usr/local/lib/perl5/archname/5.00404 ``` -------------------------------- ### Configure and Setup Plugin Source: https://metacpan.org/pod/Egg%3A%3AModel%3A%3AAuth%3A%3APlugin%3A%3AKeep Example configuration for the authentication model and plugin registration. ```perl package MyApp::Model::Auth::MyAuth;..........__PACKAGE__->config( check_sum => 'abcdefghijklmnopqrstu', delimiter => ' : ', param_name => '__auto_login', cookie => { ........... }, crypt => { ........... }, );__PACKAGE__->setup_plugin(qw/ Keep /);__PACKAGE__->setup_session('SessionKit'); ``` -------------------------------- ### Configure and Start a Service Source: https://metacpan.org/pod/Ubic Initial setup and service registration using the ubic-admin tool and configuration files. ```bash Configure ubic:$ ubic-admin setupWrite the service config:$ cat >/etc/ubic/service/foo.ini[options]bin = /usr/bin/foo.plStart your service:$ ubic start fooEnjoy your daemonized, monitored service. ``` -------------------------------- ### Setup development environment Source: https://metacpan.org/dist/NBI-Slurm/contribute Install dependencies and run tests using Dist::Zilla. ```bash cpanm Dist::Zilla dzil authordeps --missing | cpanm dzil listdeps --missing | cpanm dzil test ``` -------------------------------- ### Install and Start Minikube Source: https://metacpan.org/pod/Kubernetes%3A%3AREST%3A%3AExample Commands to install Minikube on Debian/Ubuntu and start a cluster using the Docker driver. ```bash # Install (Debian/Ubuntu)curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64sudo install minikube-linux-amd64 /usr/local/bin/minikube# Start with Docker driverminikube start --driver=docker# Verifyminikube status ``` -------------------------------- ### Configuration Model Initialization Source: https://metacpan.org/dist/Config-Model/source/lib/Config/Model/Loader.pm?raw=1 Example setup for defining a configuration model and creating an instance. ```perl use Config::Model; # define configuration tree object my $model = Config::Model->new; $model->create_config_class( name => "Foo", element => [ foo => { type => 'leaf', value_type => 'string' }, bar => '*foo', ] ); $model ->create_config_class ( name => "MyClass", element => [ foo => { type => 'leaf', value_type => 'string' }, bar => '*foo', hash_of_nodes => { type => 'hash', # hash id index_type => 'string', cargo => { type => 'node', config_class_name => 'Foo' }, }, lista => { type => 'list', cargo => { type => 'leaf', value_type => 'string' } }, listb => '*lista', ], ) ; my $inst = $model->instance(root_class_name => 'MyClass' ); my $root = $inst->config_root ; ``` -------------------------------- ### Initialize and Use Module::Start Source: https://metacpan.org/pod/Module%3A%3AStart Demonstrates the initial configuration process and the creation of a new module distribution using a specific flavor. ```bash > # start a Catalyst plugin > module-start Catalyst::Model::Funky catalyst You don't appear to have module-start configured. Would you like to do that now? [Yn] y What is your full name? Jimmy James What is your email address? jj@example.com Can I configure module-start in /home/jj/.module-start? [Yn] y Creating /home/jj/.module-start Changing to directory /home/jj/.module-start Creating ./config Installing Default Flavor Creating ./templates/basic *Error* No flavor 'catalyst' found in /home/jj/.module-start/templates/ Please install or create a 'catalyst' flavor and try again Exiting... > cpan Module::Start::Flavor::Catalyst ... (cpan installs Module::Start::Flavor::Catalyst) ... > module-start -install Module::Start::Flavor::Catalyst Installing Flavor 'catalyst' Changing to directory /home/jj/.module-start Creating ./templates/catalyst Module::Start::Flavor::Catalyst successfully installed > module-start Catalyst::Model::Funky catalyst Creating module distribution Catalyst-Model-Funky Changing to directory Catalyst-Model-Funky Using 'catalyst' flavor templates Creating Makefile.PL Creating Changes Creating lib/Catalyst/Model/Funky.pm Creating t/00_load.t Creating README Creating MANIFEST Catalyst-Model-Funky successfully started ``` -------------------------------- ### Run with Live Container Source: https://metacpan.org/pod/App%3A%3Adozo Example of starting a live container with a specific image. ```bash dozo -I tecolicom/xlate -L ``` -------------------------------- ### Skip tests during installation Source: https://metacpan.org/pod/cpanp Example command to install a module while skipping its tests. ```bash cpanp -i --skiptest MODULE ... ``` -------------------------------- ### Run and Implement a Server with Server::Starter Source: https://metacpan.org/pod/Server%3A%3AStarter Demonstrates starting the server from the command line and implementing the server program to accept connections using file descriptors provided by the module. ```perl # from command line % start_server --port=80 my_httpd # in my_httpd use Server::Starter qw(server_ports); my $listen_sock = IO::Socket::INET->new( Proto => 'tcp', ); $listen_sock->fdopen((values %{server_ports()})[0], 'w') or die "failed to bind to listening socket:$!"; while (1) { if (my $conn = $listen_sock->accept) { .... } } ``` -------------------------------- ### Invalid regex quantifier start Source: https://metacpan.org/pod/Padre%3A%3ADocument%3A%3APerl%3A%3ABeginner Example of a regular expression starting with a quantifier. ```perl /+.../ ``` -------------------------------- ### Get Installation Version Source: https://metacpan.org/release/ANDK/CPAN-2.38/source/lib/CPAN/Bundle.pm Retrieves the version of the installed bundle file, triggering an installation file search as a side effect. ```perl sub inst_version { my($self) = @_; $self->inst_file; # finds INST_VERSION as side effect $self->{INST_VERSION}; } ``` -------------------------------- ### Initialize a new site Source: https://metacpan.org/pod/HiD%3A%3AApp%3A%3ACommand%3A%3Ainit Example usage of the init command and the resulting directory structure and configuration file. ```bash $ ../bin/hid init Enjoy your new site! $ ls _config.yml _includes/ _layouts/ _site/ $ cat _config.yml --- title: My Great New Site --- ``` -------------------------------- ### POST /setup/start Source: https://metacpan.org/dist/Mojolicious-Plugin-Fondation-Setup/view/README.md Initialize the wizard session state. ```APIDOC ## POST /setup/start ### Description Builds the session state based on the plugins selected by the user. ### Method POST ### Endpoint /setup/start ``` -------------------------------- ### Install Examples::Generator via cpanm Source: https://metacpan.org/pod/Examples%3A%3AGenerator Command to install the distribution using cpanm. ```bash cpanm Examples::Generator ``` -------------------------------- ### Configuration File Example Source: https://metacpan.org/pod/Net%3A%3AServer%3A%3APreFork A sample configuration file for Net::Server::PreFork defining server parameters, user/group settings, logging, and port bindings. ```text #-------------- file test.conf --------------### server informationmin_servers 20max_servers 80min_spare_servers 10min_spare_servers 15max_requests 1000### user and group to becomeuser somebodygroup everybody### logging ?log_file /var/log/server.loglog_level 3pid_file /tmp/server.pid### access controlallow .+\.(net|com)allow domain\.comdeny a.+### background the process?background 1### ports to bindhost 127.0.0.1port localhost:20204port 20205### reverse lookups ?# reverse_lookups on### enable child communication ?# child_communication#-------------- file test.conf -------------- ``` -------------------------------- ### $hello->start Source: https://metacpan.org/pod/Mojo%3A%3AHelloWorld Starts the application instance. ```APIDOC ## Method: start ### Description Starts the Mojo::HelloWorld application instance. ### Signature `$hello->start;` ``` -------------------------------- ### Get entry date HTML example Source: https://metacpan.org/pod/App%3A%3APlog%3A%3ARenderer%3A%3AHTML%3A%3APod Example output format for the get_entry_date_html method. ```text 2009-10-0514:53:24+0200 ``` -------------------------------- ### Install Email::Pipemailer::DieHandler Source: https://metacpan.org/pod/Email%3A%3APipemailer%3A%3ADieHandler Basic installation of the die handler at the start of a Perl script. ```perl #!/usr/bin/perluse Email::Pipemailer::DieHandler -install;use strict;use warnings;# your code goes here ``` -------------------------------- ### Legacy MakeMaker installation command Source: https://metacpan.org/pod/Module%3A%3ABuild%3A%3ACookbook Example of a standard installation command using ExtUtils::MakeMaker. ```bash perl Makefile.PL PREFIX=~make testmake install UNINST=1 ``` -------------------------------- ### Example install_base path mapping Source: https://metacpan.org/pod/ExtUtils%3A%3AInstallPaths Shows how setting install_base to a specific directory like /home/ken results in a structured installation path layout. ```text lib => /home/ken/lib/perl5arch => /home/ken/lib/perl5/i386-linuxscript => /home/ken/binbin => /home/ken/binbindoc => /home/ken/man/man1libdoc => /home/ken/man/man3binhtml => /home/ken/htmllibhtml => /home/ken/html ``` -------------------------------- ### Hexify Output with Start Parameter Source: https://metacpan.org/pod/Data%3A%3AHexify Example of output when the start parameter is used to offset the index. ```text 0000: 74 61 3a 3a 48 ... 79 3b 0a 0a 75 73 65 ta::Hexify;..use0010: 20 35 2e 30 30 ... 73 65 20 73 74 72 69 5.006;.use stri... and so on ... ``` -------------------------------- ### Install Package from Generated Image Source: https://metacpan.org/dist/NBI-Slurm/view/bin/make_package Example of installing a package where the binary list is inferred from the image. ```bash make_package -i seqfu__1.20.0.simg ``` -------------------------------- ### Install Package with Explicit Binaries Source: https://metacpan.org/dist/NBI-Slurm/view/bin/make_package Example of installing a package while explicitly listing the binaries to be linked. ```bash make_package -i seqfu__1.20.0.simg seqfu fu-orf fu-msa fu-rename fu-tabcheck ``` -------------------------------- ### Define setup() method properties Source: https://metacpan.org/pod/CGI%3A%3AApplication Lists the methods typically configured within the setup() method. ```text mode_param() - set the name of the run mode CGI param.start_mode() - text scalar containing the default run mode.error_mode() - text scalar containing the error mode.run_modes() - hash table containing mode => function mappings.tmpl_path() - text scalar or array reference containing path(s) to template files. ``` -------------------------------- ### Usage Examples Source: https://metacpan.org/dist/Megaport/source/lib/Megaport/Internal/_Result.pm Examples demonstrating how to use the get and list methods to retrieve data from the API. ```perl my $eq1 = $mp->session->locations->get(id => 2); say $eq1->name, $eq1->address->{street}; ``` ```perl # Optional array or arrayref my @list = $locations->list; my $list = $locations->list; # Use search terms to find a partial list my @oceania = $locations->list(networkRegion => 'ANZ'); my @uk = $locations->list(country => 'United Kingdom'); # Or use a regexp to get a bit fancy my @dlr = $locations->list(name => qr/^Digital Realty/); ``` ```perl my $gs = $locations->get(id => 3); my $sy3 = $locations->get(name => 'Equinix SY3'); ``` -------------------------------- ### MyApp->setup Source: https://metacpan.org/pod/Catalyst Initializes the dispatcher, engine, plugins, and application components. ```APIDOC ## MyApp->setup ### Description Initializes the dispatcher and engine, loads plugins, and loads model, view, and controller components. Plugins can be specified as arguments if not loaded via 'use Catalyst'. ### Usage MyApp->setup; MyApp->setup( qw/-Debug/ ); ### Note Do not wrap this method with method modifiers; use setup_finalize instead. ``` -------------------------------- ### GET Request Example Source: https://metacpan.org/dist/MPMinus/view/eg/MPM/Waldo.pm Example of a curl request to the /waldo endpoint and the resulting JSON response. ```bash curl -v --raw -H "Accept: application/json" http://localhost/waldo?bar=123> GET /waldo?bar=123 HTTP/1.1> Host: localhost> User-Agent: curl/7.50.1> Accept: application/json>< HTTP/1.1 200 OK< Date: Thu, 25 Apr 2019 12:30:55 GMT< Server: Apache/2.4.18 (Ubuntu)< Content-Length: 528< Content-Type: application/json<{ "key" : "GET#/#default", "uri" : "/waldo", "dvars" : { "debug" : "on", "testvalue" : "Blah-Blah-Blah", "location" : "waldo" }, "remote_addr" : "127.0.0.1", "name" : "getIndex", "usr" : { "bar" : "123" }, "stamp" : "[26264] MPM::Foo at Thu Apr 25 15:30:55 2019", "code" : 200, "error" : "", "foo_attr" : "My foo attribute value", "servers" : [ "MPM-Foo#waldo" ], "path" : "/", "server_status" : 1, "debug_time" : "0.003", "location" : "waldo"} ``` -------------------------------- ### CPAN Distribution Installation and Cleanup Logic Source: https://metacpan.org/release/ANDK/CPAN-2.38/source/lib/CPAN/Distribution.pm Handles the installation process, environment variable setup, and conditional cleanup of build directories after successful installation. ```perl "Do you want to install it permanently?", $default); } } unless ($want_install =~ /^y/i) { my $is_only = "is only 'build_requires'"; $self->{install} = CPAN::Distrostatus->new("NO -- $is_only"); delete $self->{force_update}; $self->goodbye("Not installing because $is_only"); $self->post_install(); return; } local $ENV{PERL5LIB} = defined($ENV{PERL5LIB}) ? $ENV{PERL5LIB} : ($ENV{PERLLIB} || ""); local $ENV{PERL5OPT} = defined $ENV{PERL5OPT} ? $ENV{PERL5OPT} : ""; local $ENV{PERL_USE_UNSAFE_INC} = exists $ENV{PERL_USE_UNSAFE_INC} && defined $ENV{PERL_USE_UNSAFE_INC} ? $ENV{PERL_USE_UNSAFE_INC} : 1; # install $CPAN::META->set_perl5lib; local $ENV{PERL_MM_USE_DEFAULT} = 1 if $CPAN::Config->{use_prompt_default}; local $ENV{NONINTERACTIVE_TESTING} = 1 if $CPAN::Config->{use_prompt_default}; my $install_env; if ($self->prefs->{install}) { $install_env = $self->prefs->{install}{env}; } local @ENV{keys %$install_env} = values %$install_env if $install_env; if (! $run_allow_installing_within_test) { my($allow_installing, $why) = $self->_allow_installing; if (! $allow_installing) { $CPAN::Frontend->mywarn("Installation stopped: $why\n"); $self->introduce_myself; $self->{install} = CPAN::Distrostatus->new("NO -- installation stopped due $why"); $CPAN::Frontend->mywarn(" $system -- NOT OK\n"); delete $self->{force_update}; $self->post_install(); return; } } my($pipe) = FileHandle->new("$system $stderr |"); unless ($pipe) { $CPAN::Frontend->mywarn("Can't execute $system: $!"); $self->introduce_myself; $self->{install} = CPAN::Distrostatus->new("NO"); $CPAN::Frontend->mywarn(" $system -- NOT OK\n"); delete $self->{force_update}; $self->post_install(); return; } my($makeout) = ""; while (<$pipe>) { print $_; # intentionally NOT use Frontend->myprint because it # looks irritating when we markup in color what we # just pass through from an external program $makeout .= $_; } $pipe->close; my $close_ok = $? == 0; $self->introduce_myself; if ( $close_ok ) { $CPAN::Frontend->myprint(" $system -- OK\n"); $CPAN::META->is_installed($self->{build_dir}); $self->{install} = CPAN::Distrostatus->new("YES"); if ($CPAN::Config->{'cleanup_after_install'} && ! $self->is_dot_dist && ! $self->is_being_sponsored) { my $parent = File::Spec->catdir( $self->{build_dir}, File::Spec->updir ); chdir $parent or $CPAN::Frontend->mydie("Couldn't chdir to $parent: $!\n"); File::Path::rmtree($self->{build_dir}); my $yml = "$self->{build_dir}.yml"; if (-e $yml) { unlink $yml or $CPAN::Frontend->mydie("Couldn't unlink $yml: $!\n"); } $self->{cleanup_after_install_done}=1; } } else { $self->{install} = CPAN::Distrostatus->new("NO"); $CPAN::Frontend->mywarn(" $system -- NOT OK\n"); my $mimc = CPAN::HandleConfig->prefs_lookup($self, q{make_install_make_command}); if ( $makeout =~ /permission/s && $> > 0 && ( ! $mimc || $mimc eq (CPAN::HandleConfig->prefs_lookup($self, q{make})) ) ) { $CPAN::Frontend->myprint( qq{----\n}. qq{ You may have to su }. qq{to root to install the package\n}. qq{ (Or you may want to run something like\n}. qq{ o conf make_install_make_command 'sudo make'\n}. ``` -------------------------------- ### setup() Source: https://metacpan.org/pod/CGI%3A%3AApplication Called by the new() constructor to define application properties such as run modes, start mode, error mode, and template paths. ```APIDOC ## setup() ### Description This method is called by the inherited new() constructor. It is used to define application configuration including run modes, start mode, error mode, and template paths. ### Usage Implement this method in your sub-class to configure your application instance. ### Configuration Methods - **mode_param()**: Set the name of the run mode CGI parameter. - **start_mode()**: Set the default run mode. - **error_mode()**: Set the error mode. - **run_modes()**: Define a hash table mapping modes to function names. - **tmpl_path()**: Set the path(s) to template files. ``` -------------------------------- ### Install Setup::File::Layout via cpanm Source: https://metacpan.org/pod/Setup%3A%3AFile%3A%3ALayout Use cpanm to install the module directly from the terminal. ```bash cpanm Setup::File::Layout ``` -------------------------------- ### Detailed Module::Build installation steps Source: https://metacpan.org/pod/Module%3A%3ABuild A breakdown of the installation process including the creation of the Build script and execution of specific actions. ```bash perl Build.PL # 'Build.PL' script creates the 'Build' script ./Build # Need ./ to ensure we're using this "Build" script ./Build test # and not another one that happens to be in the PATH ./Build install ``` -------------------------------- ### Initialize and use ExtUtils::InstallPaths Source: https://metacpan.org/pod/ExtUtils%3A%3AInstallPaths Demonstrates how to initialize the module with options and use it to generate an install map for ExtUtils::Install. ```perl use ExtUtils::InstallPaths;use ExtUtils::Install 'install';GetOptions(\my %opt, 'install_base=s', 'install_path=s%', 'installdirs=s', 'destdir=s', 'prefix=s', 'uninst:1', 'verbose:1');my $paths = ExtUtils::InstallPaths->new(%opt, dist_name => $dist_name);install($paths->install_map, $opt{verbose}, 0, $opt{uninst}); ``` -------------------------------- ### Example command for converting Perl documentation Source: https://metacpan.org/release/PEVANS/perl-5.45.1/view/installhtml A practical example of invoking installhtml with specific paths and configuration flags. ```bash ./installhtml --podpath=lib:ext:pod:vms \--podroot=/usr/src/perl \--htmldir=/perl/nmanual \--htmlroot=/perl/nmanual \--splithead=pod/perlipc \--splititem=pod/perlfunc \--recurse \--verbose ``` -------------------------------- ### Command line and file path examples Source: https://metacpan.org/dist/PerlBuildSystem/view/doc/pnw2004/a_pbs_slide.pod Examples of running a build command and referencing a specific Pbsfile. ```text (pbs -bi '*Bitmap*') (./gdb_example/nailara/hal/pcb/xxPbsfile.pl) ``` -------------------------------- ### Force module installation Source: https://metacpan.org/dist/CPAN/view/scripts/cpan Example of using the force flag to install a module even if tests fail. ```bash % cpan -f -i Module::Foo ``` -------------------------------- ### Get a Blob in Perl Source: https://metacpan.org/pod/Pithub%3A%3AGitData%3A%3ABlobs Example usage of the get method to retrieve blob content from a GitHub repository. ```perl my $b = Pithub::GitData::Blobs->new;my $result = $b->get( user => 'plu', repo => 'Pithub', sha => 'b7cdea6830e128bc16c2b75efd99842d971666e2',); ``` -------------------------------- ### Initialize and use App::karr::BoardStore Source: https://metacpan.org/pod/App%3A%3Akarr%3A%3ABoardStore Demonstrates basic instantiation and common operations like loading configuration, allocating IDs, and retrieving tasks. ```perl my $store = App::karr::BoardStore->new( git => $git );my $config = $store->load_config;my $id = $store->allocate_next_id;my @tasks = $store->load_tasks; ``` -------------------------------- ### Install HiD with cpanm Source: https://metacpan.org/release/GENEHACK/HiD-1.992/source/INSTALL Use cpanm for a simple, automated installation that handles local::lib setup if necessary. ```bash % cpanm HiD ``` -------------------------------- ### POST /setup/execute Source: https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AFondation%3A%3ASetup Processes setup actions. ```APIDOC ## POST /setup/execute ### Description Processes next, back, or save actions within the setup wizard. ### Method POST ### Endpoint /setup/execute ``` -------------------------------- ### Install Setup::File::Symlink via CPAN shell Source: https://metacpan.org/pod/Setup%3A%3AFile%3A%3ASymlink Use the interactive CPAN shell to install the module. ```bash perl -MCPAN -e shell install Setup::File::Symlink ``` -------------------------------- ### Install Setup::File::Symlink via cpanm Source: https://metacpan.org/pod/Setup%3A%3AFile%3A%3ASymlink Use cpanm to quickly install the module from the command line. ```bash cpanm Setup::File::Symlink ``` -------------------------------- ### setup Source: https://metacpan.org/module/Jifty%3A%3ATest/source Initializes the test environment, including database resets and configuration merging. ```APIDOC ## Jifty::Test->setup(ARGS) ### Description Merges the test configuration into the default configuration, resets the database, and resets the fake outgoing mail folder. This method is intended to be overridden for custom setup work, such as inserting test data. ### Parameters - **ARGS** (array reference) - A reference to the array of parameters passed into the import statement. ``` -------------------------------- ### Install Setup::File::Layout via CPAN shell Source: https://metacpan.org/pod/Setup%3A%3AFile%3A%3ALayout Use the interactive CPAN shell to install the module. ```bash perl -MCPAN -e shell install Setup::File::Layout ``` -------------------------------- ### Install Examples::Generator via CPAN shell Source: https://metacpan.org/pod/Examples%3A%3AGenerator Commands to install the distribution using the interactive CPAN shell. ```bash perl -MCPAN -e shell install Examples::Generator ``` -------------------------------- ### Instantiate Net::Gotify Source: https://metacpan.org/pod/Net%3A%3AGotify Shows the constructor syntax and a practical example of initializing the client with required parameters. ```perl $gotify = Net::Gotify->new( \%params ); ``` ```perl my $gotify = Net::Gotify->new( base_url => 'http://localhost:8088', app_token => '', client_token => '', logger => $logger); ``` -------------------------------- ### Start the daemon via command line Source: https://metacpan.org/pod/Daemon%3A%3AControl Example of invoking the generated init script to start the daemon process. ```bash /home/symkat/etc/init.d/program start ``` -------------------------------- ### Initialize Client and Execute Example Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/travel/add_performance_max_for_travel_goals_campaign.pl Sets up the Google Ads client and parses command line arguments to execute the campaign creation process. ```perl if (abs_path($0) ne abs_path(__FILE__)) { return 1;}# Get Google Ads Client, credentials will be read from ~/googleads.properties.my $api_client = Google::Ads::GoogleAds::Client->new();# By default examples are set to die on any server returned fault.$api_client->set_die_on_faults(1);my $customer_id = undef;my $place_id = undef;# Parameters passed on the command line will override any parameters set in code.GetOptions( "customer_id=s" => \$customer_id, "place_id=s" => \$place_id,);# Print the help message if the parameters are not initialized in the code nor# in the command line.pod2usage(2) if not check_params($customer_id, $place_id);# Call the example.add_performance_max_for_travel_goals_campaign($api_client, $customer_id =~ s/-//gr, $place_id); ``` -------------------------------- ### Complete script example with Getopt::Long Source: https://metacpan.org/module/Pod%3A%3AUsage/source A full example demonstrating standard usage patterns including help and man page options. ```perl use strict; use Getopt::Long qw(GetOptions); use Pod::Usage qw(pod2usage); my $man = 0; my $help = 0; ## Parse options and print usage if there is a syntax error, ## or if usage was explicitly requested. GetOptions('help|?' => \$help, man => \$man) or pod2usage(2); pod2usage(1) if $help; pod2usage(-verbose => 2) if $man; ## If no arguments were given, then allow STDIN to be used only ## if it's not connected to a terminal (otherwise print usage) pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN)); __END__ =head1 NAME sample - Using GetOpt::Long and Pod::Usage =head1 SYNOPSIS sample [options] [file ...] Options: -help brief help message -man full documentation =head1 OPTIONS =over 4 =item B<-help> Prints a brief help message and exits. =item B<-man> Prints the manual page and exits. ``` -------------------------------- ### Get Relative Start Time Source: https://metacpan.org/release/ZNMSTR/Zonemaster-Backend-12.1.1/source/lib/Zonemaster/Backend/DB/PostgreSQL.pm Calculates the time difference between the current time and the start time of a test result. ```perl sub get_relative_start_time { my ( $self, $hash_id ) = @_; return $self->dbh->selectrow_array( q[ SELECT EXTRACT(EPOCH FROM ? - started_at) FROM test_results WHERE hash_id=? ], undef, $self->format_time( time() ), $hash_id, );} ``` -------------------------------- ### GET /setup/reset Source: https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AFondation%3A%3ASetup Resets the setup session. ```APIDOC ## GET /setup/reset ### Description Clears the current session and restarts the setup process. ### Method GET ### Endpoint /setup/reset ``` -------------------------------- ### Initialize and Execute Example Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/shopping_ads/add_performance_max_product_listing_group_tree.pl Sets up the Google Ads client and executes the performance max product listing group tree creation process. ```perl # Don't run the example if the file is being included. if (abs_path($0) ne abs_path(__FILE__)) { return 1; } # Get Google Ads Client, credentials will be read from ~/googleads.properties. my $api_client = Google::Ads::GoogleAds::Client->new(); # By default examples are set to die on any server returned fault. $api_client->set_die_on_faults(1); # Parameters passed on the command line will override any parameters set in code. GetOptions( "customer_id=s" => \$customer_id, "asset_group_id=i" => \$asset_group_id, "replace_existing_tree=s" => \$replace_existing_tree); # Print the help message if the parameters are not initialized in the code nor # in the command line. pod2usage(2) if not check_params($customer_id, $asset_group_id); # Call the example. add_performance_max_product_listing_group_tree( $api_client, $customer_id =~ s/-//gr, $asset_group_id, $replace_existing_tree); ``` -------------------------------- ### Set Billing Setup Date Times Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/billing/add_billing_setup.pl Queries existing approved billing setups to determine valid start and end dates for a new setup, ensuring no overlap. ```perl sub set_billing_setup_date_times { my ($api_client, $customer_id, $billing_setup) = @_; # The query to search existing approved billing setups in the end date time # descending order. # See get_billing_setup.pl for a more detailed example of how to retrieve # billing setups. my $search_query = "SELECT billing_setup.end_date_time " . "FROM billing_setup " . "WHERE billing_setup.status = 'APPROVED' " . "ORDER BY billing_setup.end_date_time DESC"; # Issue a search request. my $search_response = $api_client->GoogleAdsService()->search({ customerId => $customer_id, query => $search_query }); my $google_ads_row = $search_response->{results}[0]; my $start_date = undef; if (defined $google_ads_row) { # Retrieve the ending date time of the last billing setup. my $last_ending_date_time_string = $google_ads_row->{billingSetup}{endDateTime}; if (not $last_ending_date_time_string) { # A null ending date time indicates that the current billing setup is set # to run indefinitely. Billing setups cannot overlap, so die with error # in this case. die "Cannot set starting and ending date times for the new billing setup; " . "the latest existing billing setup is set to run indefinitely.\n"; } # Set the new billing setup to start one day after the ending date time. $start_date = str2time($last_ending_date_time_string) + 60 * 60 * 24; } else { # Otherwise, the only acceptable start date time is today. $start_date = time; } $billing_setup->{startDateTime} = strftime("%Y-%m-%d", localtime($start_date)); # Set the new billing setup to end one day after the starting date time. $billing_setup->{endDateTime} = strftime("%Y-%m-%d", localtime($start_date + 60 * 60 * 24));} ``` -------------------------------- ### Start the server Source: https://metacpan.org/pod/Map%3A%3ATube%3A%3AServer Launch the local server using plackup. ```bash $ plackup server.psgiHTTP::Server::PSGI: Accepting connections at http://0:5000/ ``` -------------------------------- ### Perform a basic HTTP GET request Source: https://metacpan.org/pod/AnyEvent%3A%3AHTTP A simple example of initiating an asynchronous GET request using the http_get function. ```perl use AnyEvent::HTTP;http_get "http://www.nethype.de/", sub { print $_[1] };# ... do something else here ``` -------------------------------- ### Alternative Module::Starter Implementation Approaches Source: https://metacpan.org/release/SZABGAB/Padre-1.02/source/lib/Padre/Wx/Dialog/ModuleStarter.pm Commented-out examples showing alternative ways to invoke Module::Starter, either via command-line strings or direct API calls. ```perl # require Padre::Util;# require Module::Starter;# my @cmd = (# '--module', $data->{module_name},# '--author', $data->{author_name},# '--email', $data->{email},# '--builder', $data->{builder_choice},# '--license', $data->{license_choice},# '--verbose',# );# my $ms_ref = Padre::Util::run_in_directory_two(cmd => "module-starter @cmd", dir => $data->{directory}, option => 0);# p $ms_ref; ``` ```perl # use Module::Starter qw(Module::Starter::Simple);# my %ms_args = (# modules => [ $data->{module_name} ],# author => $data->{author_name},# email => $data->{email},# builder => $data->{builder_choice},# license => $data->{license_choice},# basedir => $data->{directory},# verbose => 1,# ignores_type => [ 'generic', 'manifest'],# );# Module::Starter->create_distro(%ms_args); ``` -------------------------------- ### POST /setup/execute Source: https://metacpan.org/dist/Mojolicious-Plugin-Fondation-Setup/view/README.md Process wizard navigation and configuration actions. ```APIDOC ## POST /setup/execute ### Description Processes navigation actions (next/back) and saves configuration data during the wizard flow. ### Method POST ### Endpoint /setup/execute ``` -------------------------------- ### Get next set start Source: https://metacpan.org/pod/Nile%3A%3APlugin%3A%3APaginate Returns the page number at the start of the next page set, or undef if pages_per_set is not defined. ```perl print "Next set starts at ", $paginate->next_set(), "\n"; ``` -------------------------------- ### Initialize Google Ads Client and Execute Example Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/remarketing/add_conversion_based_user_list.pl Sets up the Google Ads client, parses command line arguments, and invokes the user list creation function. ```perl # Don't run the example if the file is being included.if (abs_path($0) ne abs_path(__FILE__)) { return 1;}# Get Google Ads Client, credentials will be read from ~/googleads.properties.my $api_client = Google::Ads::GoogleAds::Client->new();# By default examples are set to die on any server returned fault.$api_client->set_die_on_faults(1);# Parameters passed on the command line will override any parameters set in code.GetOptions( "customer_id=s" => \$customer_id, "conversion_action_ids=s" => \@$conversion_action_ids,);$conversion_action_ids = [$conversion_action_id_1, $conversion_action_id_2] unless @$conversion_action_ids;# Print the help message if the parameters are not initialized in the code nor# in the command line.pod2usage(2) if not check_params($customer_id, $conversion_action_ids);# Call the example.add_conversion_based_user_list($api_client, $customer_id =~ s/-//gr, $conversion_action_ids); ``` -------------------------------- ### Get previous set start Source: https://metacpan.org/pod/Nile%3A%3APlugin%3A%3APaginate Returns the page number at the start of the previous page set, or undef if pages_per_set is not defined. ```perl print "Previous set starts at ", $paginate->previous_set(), "\n"; ``` -------------------------------- ### Initialize Client and Run Example Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/shopping_ads/add_performance_max_retail_campaign.pl Sets up the Google Ads API client and parses command-line arguments to execute the campaign creation process. ```perl if (abs_path($0) ne abs_path(__FILE__)) { return 1;}# Get Google Ads Client, credentials will be read from ~/googleads.properties.my $api_client = Google::Ads::GoogleAds::Client->new();# By default examples are set to die on any server returned fault.$api_client->set_die_on_faults(1);my $customer_id = undef;my $merchant_center_account_id = undef;my $final_url = "http://www.example.com";my $brand_guidelines_enabled = "true";# Parameters passed on the command line will override any parameters set in code.GetOptions( "customer_id=s" => \$customer_id, "merchant_center_account_id=i" => \$merchant_center_account_id, "final_url=s" => \$final_url, "brand_guidelines_enabled=s" => \$brand_guidelines_enabled);# Print the help message if the parameters are not initialized in the code nor# in the command line.pod2usage(2) if not check_params( $customer_id, $merchant_center_account_id, $final_url, $brand_guidelines_enabled );# Call the example.add_performance_max_retail_campaign($api_client, $customer_id =~ s/-//gr, $merchant_center_account_id, $final_url, $brand_guidelines_enabled); ``` -------------------------------- ### Common cpanm installation commands Source: https://metacpan.org/dist/App-cpanminus/view/bin/cpanm Examples of installing modules from various sources such as CPAN, URLs, local files, and directories. ```bash cpanm Test::More # install Test::More cpanm MIYAGAWA/Plack-0.99_05.tar.gz # full distribution path cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz # install from URL cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz # install from a local file cpanm --interactive Task::Kensho # Configure interactively cpanm . # install from local directory cpanm --installdeps . # install all the deps for the current directory cpanm -L extlib Plack # install Plack and all non-core deps into extlib cpanm --mirror http://cpan.cpantesters.org/ DBI # use the fast-syncing mirror cpanm --from https://cpan.metacpan.org/ Plack # use only the HTTPS mirror ``` -------------------------------- ### install_path Source: https://metacpan.org/pod/ExtUtils%3A%3AInstallPaths Gets the install path for a specific type. ```APIDOC ## install_path($type) ### Description Gets the install path for a certain type. ``` -------------------------------- ### selectionStart Source: https://metacpan.org/pod/HTML%3A%3AObject%3A%3ADOM%3A%3AElement%3A%3AInput Gets or sets the start index of the selected text. ```APIDOC ## selectionStart ### Description Returns or sets an unsigned long representing the beginning index of the selected text. When nothing is selected, it returns the position of the text input cursor. ``` -------------------------------- ### Initialize and use Git::XS Source: https://metacpan.org/pod/Git%3A%3AXS Basic usage example showing repository initialization, status checking, adding files, committing, fetching, and pushing. ```perl use Git::XS;my $git = Git::XS->new( repo => "path/to/git/repo",);$git->init;print $git->status;$git->add('file.name');$git->commit(-m => 'It works');$git->fetch;$git->push('--all'); ``` -------------------------------- ### GET /mbutiny/report Source: https://metacpan.org/pod/App%3A%3AMBUtiny%3A%3ACollector%3A%3AServer Retrieve a report based on a start timestamp. ```APIDOC ## GET /mbutiny/report ### Description Retrieve a report based on a start timestamp. ### Method GET ### Endpoint /mbutiny/report ### Parameters #### Query Parameters - **start** (integer) - Required - Start timestamp for the report. ### Response #### Success Response (200) - **time** (float) - Execution time - **report** (array) - Report data - **status** (integer) - Status code - **error** (string) - Error message ``` -------------------------------- ### Initialize Google Ads Client and Execute Example Source: https://metacpan.org/release/MATTIAT/Google-Ads-GoogleAds-Client-33.0.0/source/examples/remarketing/add_flexible_rule_user_list.pl Sets up the Google Ads client using credentials from the environment and executes the user list creation logic. ```perl # Don't run the example if the file is being included.if (abs_path($0) ne abs_path(__FILE__)) { return 1;}# Get Google Ads Client, credentials will be read from ~/googleads.properties.my $api_client = Google::Ads::GoogleAds::Client->new();# By default examples are set to die on any server returned fault.$api_client->set_die_on_faults(1);my $customer_id = undef;# Parameters passed on the command line will override any parameters set in code.GetOptions("customer_id=s" => \$customer_id);# Print the help message if the parameters are not initialized in the code nor# in the command line.pod2usage(2) if not check_params($customer_id);# Call the example.add_combined_rule_user_list($api_client, $customer_id =~ s/-//gr); ``` -------------------------------- ### Example startup.pl for Preloading Source: https://metacpan.org/pod/Plack%3A%3AHandler%3A%3AApache2 A template for a startup.pl file to preload PSGI applications into the Apache parent process. ```perl #!/usr/bin/env perl use strict; use warnings; use Apache2::ServerUtil (); BEGIN { return unless Apache2::ServerUtil::restart_count() > 1; require lib; lib->import('/path/to/my/perl/libs'); require Plack::Handler::Apache2; my @psgis = ('/path/to/app1.psgi', '/path/to/app2.psgi'); foreach my $psgi (@psgis) { Plack::Handler::Apache2->preload($psgi); } } 1; # file must return true! ``` -------------------------------- ### GET /mbutiny/report Request Source: https://metacpan.org/pod/App%3A%3AMBUtiny%3A%3ACollector%3A%3AServer Example of retrieving a report from the server. ```bash curl -v --raw http://localhost/mbutiny/report?start=1561799700> GET /mbutiny/report HTTP/1.1> Host: localhost> User-Agent: curl/7.50.1> Accept: */*>< HTTP/1.1 200 OK< Date: Fri, 31 May 2019 05:41:34 GMT< Server: Apache/2.4.18 (Ubuntu)< Connection: close< Content-Length: 16< Content-Type: text/plain<{ "time" : 0.0012, "report" : [...], "status" : 1, "error" : ""} ``` -------------------------------- ### GET /mbutiny/list Request Source: https://metacpan.org/pod/App%3A%3AMBUtiny%3A%3ACollector%3A%3AServer Example of listing collector data. ```bash curl -v --raw http://localhost/mbutiny/list?name=foo> GET /mbutiny/list HTTP/1.1> Host: localhost> User-Agent: curl/7.50.1> Accept: */*>< HTTP/1.1 200 OK< Date: Fri, 31 May 2019 05:41:34 GMT< Server: Apache/2.4.18 (Ubuntu)< Connection: close< Content-Length: 16< Content-Type: text/plain<{ "time" : 0.0012, "list" : [...], "status" : 1, "error" : ""} ``` -------------------------------- ### Example Usage and Help Output Source: https://metacpan.org/pod/Getopt%3A%3ALong%3A%3ABash Demonstrates running the script with arguments and viewing the auto-generated help message. ```bash $ repeat.sh --count=3 --sleep=0.5 echo hellohellohellohello$ repeat.sh --helpUsage: repeat.sh [options] command...Options: --count, -c repeat count (default: 1) --sleep, -i interval time --trace, -x trace mode --debug, -d debug level (default: 0) ``` -------------------------------- ### original_prefix Source: https://metacpan.org/pod/ExtUtils%3A%3AInstallPaths Gets the original prefix for a specific installation directory. ```APIDOC ## original_prefix($installdirs) ### Description Get the original prefix for a certain type of $installdirs. ```