Fuckin-Lazy

 view release on metacpan or  search on metacpan

lib/Fuckin/Lazy.pm  view on Meta::CPAN

    my ($caller, $file, $line) = caller();

    open(my $fh, '<', $file) || die "Could not open $file: $!";

    my $updated = 0;
    my @lines;
    while (my $line = <$fh>) {
        if ($line =~ m/(LAZY|Fuckin'Lazy|Fuckin::Lazy)\s*\(/) {
            my $match = $1;
            croak "$1() must be called with parentheses, and must be given a scalar variable for an arg."
                unless $line =~ m/$match\(\s*\$[0-9A-Za-z_]+\s*\)/;

            my $data = produce_data($struct, $line, $match);
            $line =~ s/$match\(\s*\$[0-9A-Za-z_]+\s*\)/$data/;
        }
        push @lines => $line;
    }

    close($fh);
    open($fh, '>', $file) || die "Cannot open $file for writing: $!";

    print $fh @lines;

    return $struct;



( run in 0.364 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )