Created
August 19, 2013 21:16
-
-
Save manchicken/6274288 to your computer and use it in GitHub Desktop.
PLEASE NOTE: koding.com VMs are now able to install more sane environments. This is just a way of demonstrating now I used to do it way back upon launch: http://goo.gl/wqi0B3
This file contains 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
# ~/Sites/WEBSITENAME/website/lib/Koding.pm | |
use strict;use warnings; | |
package Koding; | |
{ | |
package KodingPaths; | |
use FindBin ('$Bin'); | |
sub _koding_get_home { | |
my $script_name = $Bin; | |
my @pieces = split(m!/!x, $script_name); | |
my @to_return = (); | |
my $home_path = ""; | |
for my $piece (@pieces) { | |
if ($piece eq 'Sites') { | |
last; # We've arrived at the home directory | |
} | |
push(@to_return, $piece); | |
} | |
$home_path = (join('/', @to_return)) || ""; | |
return $home_path || ""; | |
} | |
our $koding_home = ""; | |
sub BEGIN { | |
$koding_home = _koding_get_home(); | |
} | |
use lib "$koding_home/local/lib64/perl5/auto", | |
"$koding_home/local/share/perl5", | |
"$koding_home/local/lib/perl5", | |
"$koding_home/local/lib/perl5/x86_64-linux-thread-multi"; | |
}; | |
1; | |
## Now, within your script: | |
use FindBin '$Bin'; | |
use lib "$Bin/../lib/"; # Assuming subdirectory. If you're in the top-level get rid of the ../ | |
use Koding; | |
use SomeModuleName::Here; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment