my $relSourcePath; my $inlineCFile; my $inlineBuildDir; my $libDir; my $incDir; BEGIN { # this file is in the same directory as the rest of the sources $relSourcePath = File::Spec->rel2abs(dirname($0)); die "Install path must not have spaces.\n" if $relSourcePath =~ /\s/; # Need to build the path to the Inline C file here, so that we could # reference it below my @dirs = (); push @dirs, $relSourcePath; $inlineCFile = File::Spec->catfile(@dirs, "my_wrapper.c"); push @dirs, ".Inline"; $inlineBuildDir = File::Spec->catdir(@dirs); pop @dirs; push @dirs, "lib"; $libDir = File::Spec->catdir(@dirs); pop @dirs; push @dirs, "include"; $incDir = File::Spec->catdir(@dirs); } use Inline ( C => Config => LIBS => "-L$libDir -lmylib", INC => "-I$incDir", DIRECTORY => $inlineBuildDir, ); # this is the C source file for interfacing to the library. Yes, this could be # done natively in Perl, but this is just as easy (and probably faster to # execute). use Inline C => "$inlineCFile"; $ENV{MYVAR} = "my_var_value"; print "ENV{MYVAR} = '" . qqq("MYVAR") . "'\n";