Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How to exit a perl script without looking anything after it

by juo (Curate)
on Jan 23, 2001 at 10:29 UTC ( [id://53682]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

juo has asked for the wisdom of the Perl Monks concerning the following question:

How can I exit a Perl script without looking at any code in the perl script after I have placed an exit. I tried exit; but it still looks at the code after my exit and gives error messages. Pieter
  • Comment on How to exit a perl script without looking anything after it

Replies are listed 'Best First'.
Re: How to exit a perl script without looking anything after it
by azatoth (Curate) on Jan 23, 2001 at 10:35 UTC
    Well, If you're looking to put stops in the code that will exit after an "error", you can use the die command.
    open(FH,"log.log") || die "Cannot open log.log : $!\n";
    After looking at your other question, and trying to answer it, I would suggest reading "Learning Perl, 2nd Edition".

    Go to www.oreilly.com and check it out.

    Remember : Always search the perlmonks.org site for keywords before asking a question. If you don't find it here, try www.google.com. If you don't find it there, ask away. :)

    Azatoth a.k.a Captain Whiplash

    Get YOUR PerlMonks Stagename here!
Re: How to exit a perl script without looking anything after it
by davorg (Chancellor) on Jan 23, 2001 at 10:38 UTC

    What do you mean by 'looks at'?

    Are you trying to prevent some code from being compiled? In that case you can't do it using exit as Perl compiles the whole file before executing it.

    Perhaps you could comment out the code that you don't want compiled? Using =pod ... =cut is a good way to comment out large chunks of code.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: How to exit a perl script without looking anything after it
by Blue (Hermit) on Jan 23, 2001 at 11:42 UTC
    If you have code that you'd like the program to ignore, put it after a __END__. That tells Perl that there is no more code after that.

    =Blue
    ...you might be eaten by a grue...

Re: How to exit a perl script without looking anything after it
by dsb (Chaplain) on Jan 23, 2001 at 16:21 UTC
    You probably want to try commenting said code out. The interpreter will compile any code it finds. As far as Perl knows, your exit could be on only one branch of a conditional statement. POD format commenting is a good way to comment out large chunks of code. -kel

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://53682]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.