Skip to content

Instantly share code, notes, and snippets.

Created September 15, 2009 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/187268 to your computer and use it in GitHub Desktop.
Save anonymous/187268 to your computer and use it in GitHub Desktop.
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!/usr/bin/perl
#line 15
use 5.008005;
use strict;
use warnings;
use File::Which ();
use Getopt::Long ();
use Carp ();
$| = 1;
if ($ENV{PADRE_DIE}) {
$SIG{__DIE__} = sub { print STDERR Carp::longmess "\nDIE: @_\n" . ("-" x80) . "\n" };
}
# Must run using wxPerl on OS X.
if ( $^O eq 'darwin' and $^X !~ m{/wxPerl\.app/} ) {
my $perl = scalar File::Which::which('wxPerl');
chomp($perl);
if ( -e $perl ) {
warn "spawning 'wxPerl' interpreter for OS X\n";
system( $perl, '-S', $0, @ARGV );
} else {
warn "padre cannot find wxPerl executable (which it requires on OS X)\n" ;
}
exit 0;
}
# Handle special command line cases early, because options like --home
# MUST be processed before the Padre.pm library is loaded.
my $USAGE = '';
my $VERSION = '';
my $HOME = undef;
my $session = undef;
my $getopt = Getopt::Long::GetOptions(
'help' => \$USAGE,
'home=s' => \$HOME,
'session=s' => \$session,
'version' => \$VERSION,
);
if ( $USAGE or ! $getopt ) {
print <<"END_USAGE";
Usage: $0 [FILENAMES]
--home=dir Forces Padre's "home" directory to a specific location
--help Shows this help message
--session=name Open given session during Padre startup
--version Prints Padre version and quits
END_USAGE
exit(1);
}
if ( defined $HOME ) {
$ENV{PADRE_HOME} = $HOME;
}
require threads;
require threads::shared;
$ENV{PADRE_PAR_PATH} = $ENV{PAR_TEMP}||'';
my %opts = (
files => \@ARGV,
session => $session,
);
require Padre;
if ( $VERSION ) {
print "Perl Application Development and Refactoring Environment $Padre::VERSION\n";
exit(0);
}
my $app = Padre->new(%opts);
unless ( $app ) {
# Single instance worked correctly
exit(0);
}
# Start the application
$app->run;
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
__END__
:endofperl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment