This file is indexed.

/usr/share/perl5/Poet/Script.pm is in libpoet-perl 0.15-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
package Poet::Script;
$Poet::Script::VERSION = '0.15';
use Cwd qw(realpath);
use File::Spec::Functions qw(rel2abs);
use Method::Signatures::Simple;
use Poet::Environment;
use Poet::Tools qw(can_load dirname read_file);
use strict;
use warnings;

method import ($pkg:) {
    unless ( Poet::Environment->current_env ) {
        my $root_dir = determine_root_dir();
        my $poet     = initialize_with_root_dir($root_dir);
    }
    Poet::Environment->current_env->importer->export_to_level( 1, @_ );
}

func initialize_with_root_dir ($root_dir) {
    my ($app_name) = ( read_file("$root_dir/.poet_root") =~ /app_name: (.*)/ )
      or die "cannot find app_name in $root_dir/.poet_root";

    return Poet::Environment->initialize_current_environment(
        root_dir => $root_dir,
        app_name => $app_name
    );
}

func determine_root_dir () {

    # Search for .poet_root upwards from current directory, using rel2abs
    # first, then realpath.
    #
    my $path1    = dirname( rel2abs($0) );
    my $path2    = dirname( realpath($0) );
    my $root_dir = search_upward($path1) || search_upward($path2);
    unless ( defined $root_dir ) {
        die sprintf( "could not find .poet_root upwards from %s",
            ( $path1 eq $path2 ) ? "'$path1'" : "'$path1' or '$path2'" );
    }
    return $root_dir;
}

func search_upward ($path) {
    my $count = 0;
    while ( realpath($path) ne '/' && $count++ < 10 ) {
        if ( -f "$path/.poet_root" ) {
            return realpath($path);
            last;
        }
        $path = dirname($path);
    }
    return undef;
}

1;

__END__

=pod

=head1 NAME

Poet::Script -- Intialize Poet for a script

=head1 SYNOPSIS

    # In a script...
    use Poet::Script qw($cache $conf $poet $log :file);

=head1 DESCRIPTION

This module is used to initialize Poet for a script. It does the following:

=over

=item *

Determines the environment root by looking upwards from the directory of the
current script until it finds the Poet marker file (C<.poet_root>).

=item *

Reads and parses configuration files.

=item *

Shifts the C<lib/> subdirectory of the environment root onto C<@INC>.

=item *

Imports the specified I<quick vars> and utility sets into the current package -
see L<Poet::Import|Poet::Import>.

=back

=head1 SEE ALSO

L<Poet|Poet>

=head1 AUTHOR

Jonathan Swartz <swartz@pobox.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut