#!/usr/bin/env perl use strict; # This script will recombine the perltidy binary script and all of its # modules into a single, monolithic script, which is how it was # originally distributed. It might be useful for users who have # difficulty installing modules, or prefer not to. # usage: # perl pm2pl # Run this from the perltidy main installation directory. It reads # bin/perltidy and lib/*.pm and writes a file 'perltidy' in the # current directory. # Then, put the file 'perltidy' in your path and it should work (You # will also need to put the batch file 'perltidy.bat' in your path # under msdos/windows) # For unix systems, a sample Makefile is included as Makefile.npm # This should work for a system with File::Spec, # and for older Windows/Unix systems without File::Spec. my $script = 'bin/perltidy'; my $module = 'lib/Perl/Tidy.pm'; eval "use File::Spec;"; my $missing_file_spec = $@; unless ($missing_file_spec) { $script = File::Spec->catfile( 'bin', 'perltidy' ); $module = File::Spec->catfile( 'lib', 'Perl', 'Tidy.pm' ); } my $outfile = "perltidy"; open OUTFILE, "> $outfile" or die "can't open file '$outfile' : $!\n"; print "Creating file '$outfile' ....\n "; # first, open the script and copy the first (hash-bang) line # (Note: forward slashes in file names here will work in Windows) open SCRIPT, "< $script" or die "can't open script file '$script' : $!\n"; my $hash_bang =