5 use File::Slurp 'slurp';
6 use List::MoreUtils 'uniq';
8 unlink 'lib/Mouse/Tiny.pm';
16 && !/Squirrel|MouseX|\.sw[po]$/
24 for my $file (uniq 'lib/Mouse/Util.pm', sort @files) {
25 my $contents = slurp $file;
27 $contents =~ s/__END__\b.*//s; # remove documentation
28 $contents =~ s/1;\n*$//; # remove success indicator
30 $contents =~ s/^use Mouse\S*\s*\n//mg; # we're already loading everything
31 $contents =~ s/^use (Mouse\S*)\s*(.+);/BEGIN { $1->import($2) }/mg;
33 $mouse_tiny .= $contents;
36 open my $handle, '>lib/Mouse/Tiny.pm' or die "Can't write lib/Mouse/Tiny.pm: $!";
38 print { $handle } << 'EOF';
39 # THIS FILE IS AUTOGENERATED!
41 # if regular Mouse is loaded, bail out
42 unless ($INC{'Mouse.pm'}) {
45 # tell Perl we already have all of the Mouse files loaded:
48 for my $file (@files) {
49 (my $inc = $file) =~ s{^lib/}{};
50 print { $handle } "\$INC{'$inc'} = __FILE__;\n";
53 print { $handle } "\n# and now their contents\n\n";
55 print { $handle } $mouse_tiny;
57 print { $handle } "}; #eval\n} #unless\n\n";
59 print { $handle } << 'EOF';
65 print { $handle } "1;\n\n";