The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::Script - Script Base Class

SYNOPSIS

    use base 'Mojo::Script';

    sub run {
        my $self = shift;
        $self->render_to_rel_file('foo_bar', 'foo/bar.txt');
    }

    1;
    __DATA__
    __foo_bar__
    % for (1 .. 5) {
        Hello World!
    % }

DESCRIPTION

Mojo::Script is a base class for scripts.

ATTRIBUTES

description

    my $description = $script->description;
    $script         = $script->description('Foo!');

quiet

    my $quiet = $script->quiet;
    $script   = $script->quiet(1);

METHODS

Mojo::Script inherits all methods from Mojo::Base and implements the following new ones.

chmod_file

    $script = $script->chmod_file('/foo/bar.txt', 0644);

chmod_rel_file

    $script = $script->chmod_rel_file('foo/bar.txt', 0644);

class_to_file

    my $file = $script->class_to_file('Foo::Bar');

class_to_path

    my $path = $script->class_to_path('Foo::Bar');

create_dir

    $script = $script->create_dir('/foo/bar/baz');

create_rel_dir

    $script = $script->create_rel_dir('foo/bar/baz');

get_data

    my $data = $script->get_data('foo_bar');

rel_dir

    my $path = $script->rel_dir('foo/bar');

rel_file

    my $path = $script->rel_file('foo/bar.txt');

render_data

    my $data = $script->render_data('foo_bar', @arguments);

render_to_file

    $script = $script->render_to_file('foo_bar', '/foo/bar.txt');

render_to_rel_file

    $script = $script->render_to_rel_file('foo_bar', 'foo/bar.txt');
    $script = $script->render_to_rel_file('foo_bar', 'foo/bar.txt');

run

    $script = $script->run(@ARGV);

write_file

    $script = $script->write_file('/foo/bar.txt', 'Hello World!');

write_rel_file

    $script = $script->write_rel_file('foo/bar.txt', 'Hello World!');