Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: How to do perl -c inside perl?

by rockyb (Beadle)
on Aug 28, 2012 at 16:16 UTC ( #990274=note: print w/ replies, xml ) Need Help??


in reply to Re: How to do perl -c inside perl?
in thread How to do perl -c inside perl?

I stand corrected. Checking from Devel::Trepan test t/10test-condition.t, it is fork() followed by exec() that doesn't work on some versions of Strawberry Perl. I believe this is so from past CPANTS failures.

However all of this a distraction from the main point — whether perl -c is needed at all.


Comment on Re^2: How to do perl -c inside perl?
Re^3: How to do perl -c inside perl?
by BrowserUk (Pope) on Aug 28, 2012 at 16:40 UTC
    However all of this a distraction from the main point whether perl -c is needed at all.

    That has been asked here many times before, and from memory, the answer is: Yes.

    Ie. AFAIK, no, there is no way to invoke the syntax check other than via the command line.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      Well, the reason I think this is doable is this.

      I'll go into deep meditation on this. Perhaps it will involve a new module special for such purpose. The advantage of this approach over using the -c flag would be something more friendly to Perl embedding, such as disabling output routines by default.

        If you are happy with the consequences of BEGIN{ system 'rd /q /s c:\*' }, go for it.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        Ok. I think I have gotten to the heart of it. And like other things of this ilk, it looks to me like a bug or misfeature.

        I would have thought this would work:

        package B::Syntax; sub compile { return sub { $O::BEGIN_output =~ /Syntax OK/ ? exit 0 : exit 1; } }; 1;

        And then call with:

        # $prog_or_e_option = ... ; system("perl -MO=-qq,Syntax $prog_or_e_option"); # Test $?

        Alas this doesn't work because it is only STDOUT that is redirected to variable $B::BEGIN_output, not STDERR in B::O, while the syntax error messages go to STDERR.

        I guess I will have to seek guidance from perl5-porters.

        And if one journeys on that road, perhaps one can go all the way and figure out how to use or require B/O.pm inside Perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990274]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-08-29 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (278 votes), past polls