in reply to Inline::C Needed for Win32, Want it Off For UNIX

You already have a good answer but I thought I'd add on and tell you why your Win32 syntax didn't work. Its broken as-is. The use Inline C statement is executed during BEGIN-time regardless of whether the if() condition is true or not. That is, use() does a require() and import() during the compilation time and isn't affected at all about what happens later when the if() executes.

Actual results

use Inline C => DATA => NAME => 'inline_code_pl_2d59'; if ( $^O eq 'MSWin32' ) { # Do nothing }

What you could have written that would have worked on both unix and Win32.

BEGIN { if ( $^O eq 'MSWin32' ) { # Option A require Inline; Inline->import( C => DATA => NAME => 'inline_code_pl_2d59' ); # Option B eval "use Inline C => DATA => NAME => 'inline_code_pl_2d59'"; die $@ if $@; # Option B with line numbers that make sense if die() happens eval "#line " . ( 1 + __LINE __ ) . " \"" . __FILE __ . "\"\n" . "use Inline C => DATA => NAME => 'inline_code_pl_2d59' +"; die $@ if $@; } }

Replies are listed 'Best First'.
Re^2: Inline::C Needed for Win32, Want it Off For UNIX
by Kapper_Coder (Initiate) on Oct 28, 2005 at 20:37 UTC
    Thanks so much for the help to both of you.

    In direct correlation to diotalevi's post, the code now reads

    BEGIN {
    if ($^O eq 'MSWin32') {
    require Inline;
    Inline->import(C => 'DATA', NAME => 'inline_code_pl_2d59');
    }
    }

    And seems to be working exactly as needed.

    Thank you

      I hope you have some indentation in the code. Its standard to indent things in blocks.

        He does -- you'll see it if you View Source -- but it doesn't show since he didn't wrap his code in <code>...</code> tags.