Created
September 28, 2017 18:16
-
-
Save autarch/f341bdf98b0cb2717098306cfecd2aaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/home/autarch/perl5/perlbrew/perls/perl-5.24.1/bin/perl | |
| use strict; | |
| use warnings; | |
| use lib '/home/autarch/.perlbrew/libs/perl-5.24.1@dev/lib/perl5'; | |
| use Getopt::Long qw( :config pass_through ); | |
| use Perl::Tidy 20160302; | |
| use Path::Class qw( file ); | |
| my $file; | |
| GetOptions( 'file:s' => \$file ); | |
| $ENV{PERL5LIB} = join ':', | |
| grep {defined} ( | |
| '/home/autarch/.perlbrew/libs/perl-5.24.1@dev/lib/perl5', | |
| ( $ENV{PERL5LIB} ? split /:/, $ENV{PERL5LIB} : () ), | |
| ); | |
| my $perltidy = '/home/autarch/.perlbrew/libs/perl-5.24.1@dev/bin/perltidy'; | |
| if ($file) { | |
| my $dir = file($file)->dir(); | |
| my $profile = q{}; | |
| DIR: | |
| while ( $dir ne '/' ) { | |
| for my $file ( | |
| $dir->file('perltidyrc'), $dir->file('.perltidyrc'), | |
| $dir->file('.perltidyallrc') | |
| ) { | |
| if ( -f $file ) { | |
| $profile = "-pro=$file"; | |
| last DIR; | |
| } | |
| } | |
| $dir = $dir->parent(); | |
| } | |
| exec "$perltidy $profile @ARGV"; | |
| } | |
| else { | |
| exec "$perltidy @ARGV"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment