in reply to Compile time problem

String eval compiles at runtime and will avoid the error in older perls (you'll have to move the declaration of $mem to avoid a scoping issue).
my $var = ''; my $mem; if($] > 5.007) { if( eval q{open ($mem, '>', \$var) } ) {print "Success\n"} } else {print "Ok\n"}

Replies are listed 'Best First'.
Re^2: Compile time problem
by syphilis (Archbishop) on Oct 06, 2007 at 15:31 UTC
    Thanks, FunkyMonk ... that looks like the "Aaaah, I see" moment I was after.

    Does that "q{}" stuff work ok on 5.00505 ? (I don't actually have a 5.00505 to test with ... though I may yet build one.)

    Cheers,
    Rob
      Good point. I don't know when q{} (etc) made their first appearance in perl.

      Just use appropriate quoting and escaping if it doesn't work, but I'm sure some Monk will appear with the answer before too long.

        Guggug... q//, qq// and qx// have been present in perl4. At least in the patchlevel 36 copy I have here... ;-)

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
A reply falls below the community's threshold of quality. You may see it by logging in.