5 use File::Slurp 'slurp';
6 use List::MoreUtils 'uniq';
9 unlink 'lib/Mouse/Tiny.pm';
26 for my $file (uniq 'lib/Mouse/Util.pm', sort @files) {
27 my $contents = slurp $file;
29 $contents =~ s/__END__\b.*//s; # remove documentation
30 $contents =~ s/1;\n*$//; # remove success indicator
32 $contents =~ s/^use Mouse\S*\s*\n//mg; # we're already loading everything
33 $contents =~ s/^use (Mouse\S*)\s*(.+);/BEGIN { $1->import($2) }/mg;
35 $mouse_tiny .= $contents;
38 open my $handle, '>lib/Mouse/Tiny.pm' or die "Can't write lib/Mouse/Tiny.pm: $!";
40 print { $handle } << 'EOF';
41 # THIS FILE IS AUTOGENERATED!
43 # if regular Mouse is loaded, bail out
44 unless ($INC{'Mouse.pm'}) {
47 # tell Perl we already have all of the Mouse files loaded:
50 for my $file (@files) {
51 (my $inc = $file) =~ s{^lib/}{};
52 print { $handle } "\$INC{'$inc'} = __FILE__;\n";
55 print { $handle } "\n# and now their contents\n\n";
57 print { $handle } $mouse_tiny;
59 print { $handle } "END_OF_TINY\n} #unless\n\n";
61 print { $handle } << 'EOF';
67 print { $handle } "1;\n\n";