5 use File::Slurp 'slurp';
6 use List::MoreUtils 'uniq';
8 unlink 'lib/Mouse/Tiny.pm';
25 for my $file (uniq 'lib/Mouse/Util.pm', sort @files) {
26 my $contents = slurp $file;
28 $contents =~ s/__END__\b.*//s; # remove documentation
29 $contents =~ s/1;\n*$//; # remove success indicator
31 $contents =~ s/^use Mouse\S*\s*\n//mg; # we're already loading everything
32 $contents =~ s/^use (Mouse\S*)\s*(.+);/BEGIN { $1->import($2) }/mg;
34 $mouse_tiny .= $contents;
37 open my $handle, '>lib/Mouse/Tiny.pm' or die "Can't write lib/Mouse/Tiny.pm: $!";
39 print { $handle } << 'EOF';
40 # THIS FILE IS AUTOGENERATED!
42 # if regular Mouse is loaded, bail out
43 unless ($INC{'Mouse.pm'}) {
46 # tell Perl we already have all of the Mouse files loaded:
49 for my $file (@files) {
50 (my $inc = $file) =~ s{^lib/}{};
51 print { $handle } "\$INC{'$inc'} = __FILE__;\n";
54 print { $handle } "\n# and now their contents\n\n";
56 print { $handle } $mouse_tiny;
58 print { $handle } "}; #eval\n} #unless\n\n";
60 print { $handle } << 'EOF';
66 print { $handle } "1;\n\n";