FunctionalPerl

 view release on metacpan or  search on metacpan

examples/logwatch  view on Meta::CPAN

        unlink $path;
    }
}

sub require_config($path) {
    my $arg = untainted($path =~ m|^\.{0,2}/| ? $path : "./$path");
    require $arg
}

use Hash::Util 'lock_hash';
my $config = require_config $configpath;

# (btw unlike 'eval' this doesn't give the code in question access to
# lexicals, right?)
lock_hash %$config;

my $REPORTMSG = "REPORT-" . rand();    # XX not enough randomness

my ($r, $w) = xpipe;

use Chj::xtmpfile;

examples/maplines  view on Meta::CPAN


my ($mappingfile) = @ARGV;

use FP::IOStream ":all";
use Chj::xopen qw(glob_to_fh);
use FP::Ops qw(cut_method unary_operator);
use Chj::TEST;

#use FP::Repl::Trap; # or Chj::Backtrace

my $config = require $mappingfile;
ref($config) eq "HASH"
    or usage "invalid mappingfile, does not return a hash ref";

my ($mapfn, $cmp) = @$config{ "map", "cmp" };

my $in  = glob_to_fh(*STDIN);
my $out = glob_to_fh(*STDOUT);

my $lines = fh_to_lines $in;

htmlgen/gen  view on Meta::CPAN

GetOptions(
    "verbose" => \$verbose,
    "help"    => sub {usage},
    "repl"    => \$opt_repl,
    "trap"    => \$opt_trap,
) or exit 1;
usage unless @ARGV == 3 or ($opt_repl and @ARGV >= 1);

our ($configpath, $inbase, $outbase) = @ARGV;

our $user_config = require $configpath;

require FP::Repl::Trap if $opt_trap;

our $config = hashset_union($user_config, $default_config);

lock_hash %$config;

our $pathtranslate = FunctionalPerl::Htmlgen::PathTranslate->new__(
    subhash($config, "is_indexpath0", "downcaps"));

lib/Chj/Packages.pm  view on Meta::CPAN


=head1 SYNOPSIS

    use Chj::Packages qw(
        package_to_requirepath
        require_package
        fallible_require_package_by_path
        xrequire_package_by_path
        );
    my $packagename = "Chj::Packages";
    my $possibly_previously_loaded_path = require_package $packagename;
    my $true_or_failure = fallible_require_package_by_path $packagename;
    # xrequire_package_by_path turns the failure into an exception.

    # related (mess?):
    # use FP::Predicates qw($package_re);

=head1 DESCRIPTION

Dealing with packages, and their loading, yet again.

lib/Chj/Packages.pm  view on Meta::CPAN


sub fallible_require_package_by_path($path) {
    __ 'require_package($path), but check that the returned path is
        the same as $path, after taking abs_path of both; not finding
        either path is an error. If the paths are not the same,
        returns an FP::Failure';
    my $path_abs = abs_path($path) // die "abs_path('$path'), given path: $!";
    my $package = path_to_package__cheap $path;    # XX hack, how to generalize?
         # Can't load by path (at least not 'properly'), so, load and then
         # check:
    my $path2     = require_package $package;
    my $path_abs2 = abs_path($path2)
        // die "abs_path('$path2'), path retrieved after loading: $!";

    if ($path_abs eq $path_abs2) {
        1
    } else {
        failure "require_package_by_path('$path'): the actually loaded package "
            . "is '$path_abs2', not '$path_abs'"
    }
}

website/gen-config.pl  view on Meta::CPAN

use utf8;
use experimental "signatures";

our ($mydir, $gitrepository);    # 'import' from main

use PXML::XHTML ":all";
use Clone 'clone';
use FP::Lazy;

# htmlgen is run with CWD set to website/
my $logocfg = require "./logo.pl";

my $css_path0 = "FP.css";

my $version_numrevisions = lazy {
    my $describe = $gitrepository->describe();
    my ($version, $maybe_numrevisions, $maybe_shorthash)
        = $describe =~ /^(.*?)(?:-(\d+)-g(.*))?\z/s
        or die "huh describe '$describe'";
    [$version, $maybe_numrevisions]
};



( run in 0.287 second using v1.01-cache-2.11-cpan-0d8aa00de5b )