Hi
Wyrdweaver,
When I run that batch file (as 'yrt.bat') I get the following output, followed by a GPF:
C:\_32\pscrpt\inline>yrt.bat
string[21] = 'perl -x -S yrt.bat '
Here's the same batch file using Inline::C (which you could install and use, since you have MinGW) instead of Win32::API:
@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 -w
#line 15
#use Inline C => Config =>
# BUILD_NOISY => 1; # See compilation output
use Inline C => <<'EOC';
SV * wrap_GetCommandLine() {
return newSVpv(GetCommandLine(), 0);
}
EOC
my $string = wrap_GetCommandLine();
print "string[".length($string)."] = '$string'\n";
# ------ padding -----------------------------------------------------
+---------------------------------
__END__
:endofperl
The first time you run that there's some compilation takes place.Subsequent runs of the batch file will not require any compilation unless the actual Inline::C code is changed, or the name of the batch file is changed.
Running that batch file (as try.bat), I get:
C:\_32\pscrpt\inline>try.bat
string[20] = 'perl -x -S try.bat '
This time there's no GPF - I don't know why try.bat reports one less trailing space than yrt.bat.
Hope this helps.
Cheers,
Rob
Update:Or, if you want to modularise it (which would make better sense) here's a very minimalistic approach:
Makefile.PL
use ExtUtils::MakeMaker;
my %options = %{
{
'NAME' => 'Win32::GetCommandLine',
'VERSION' => '0.01'
}
};
WriteMakefile(%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
GetCommandLine.xs
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
SV * wrap_GetCommandLine() {
return newSVpv(GetCommandLine(), 0);
}
MODULE = Win32::GetCommandLine PACKAGE = Win32::GetCommandLine
PROTOTYPES: DISABLE
SV *
wrap_GetCommandLine ()
t/test.t
use Win32::GetCommandLine;
print "1..1\n";
my $string = Win32::GetCommandLine::wrap_GetCommandLine();
if($string =~ /perl/) {print "ok 1\n"}
else {print "not ok 1\n"}
Win32/GetCommandLine.pm
package Win32::GetCommandLine;
require DynaLoader;
@ISA = qw(DynaLoader);
$VERSION = '0.01';
bootstrap Win32::GetCommandLine $VERSION;
1;