Skip to content

Instantly share code, notes, and snippets.

@autarch
Created September 1, 2016 20:13
Show Gist options
  • Select an option

  • Save autarch/a62812d2be4e6d5c6380db1b4e8217d7 to your computer and use it in GitHub Desktop.

Select an option

Save autarch/a62812d2be4e6d5c6380db1b4e8217d7 to your computer and use it in GitHub Desktop.
#!/home/autarch/perl5/perlbrew/perls/perl-5.24.0/bin/perl
use strict;
use warnings;
use lib '/home/autarch/.perlbrew/libs/perl-5.24.0@dev/lib/perl5';
use Getopt::Long qw( :config pass_through );
use Perl::Tidy 20120714;
use Path::Class qw( file );
my $file;
GetOptions( 'file:s' => \$file );
$ENV{PERL5LIB} = join ':',
grep {defined} (
'/home/autarch/.perlbrew/libs/perl-5.24.0@dev/lib/perl5',
( $ENV{PERL5LIB} ? split /:/, $ENV{PERL5LIB} : () ),
);
my $perltidy = '/home/autarch/.perlbrew/libs/perl-5.24.0@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