Solved

how to use exit?

Posted on 2000-04-24
7
222 Views
Last Modified: 2010-03-05
1.What's the difference between

exit (0) and exit(1)?

please give me a example.
0
Comment
Question by:li_fang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2746396
print system('perl -e "exit(0)"')/256,"\n";
print system('perl -e "exit(1)"')/256,"\n";
#perldoc -f exit
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2747355
Here is some info about exit.

exit status

Exits the current Perl process immediately with that value given by status. This could be the entire Perl script you are running,
or only a child process created by fork

If status is omitted, the function exits with 0. You shouldn't use exit to abort a subroutine if there's any chance that someone
might want to trap whatever error happened. Use die instead, which can be trapped by an eval.

Hope that helps
0
 
LVL 8

Accepted Solution

by:
shlomoy earned 10 total points
ID: 2748351
Use exit(0) if your program finishes with succes.
Use exit(1) (or any other value other than 0) - to alert that your program finished with a problem.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:meerak
ID: 2749148
To check the exit status from the shell use:
echo $? on ksh and sh and
echo $status on csh
0
 

Author Comment

by:li_fang
ID: 2749787
It's what i want!
0
 
LVL 84

Expert Comment

by:ozo
ID: 2749944
use POSIX;
exit( $? ? EXIT_FAILURE:EXIT_SUCCESS );
0
 

Author Comment

by:li_fang
ID: 2753661
hi,ozo
I can't understand your answer,you are expert,I'm beginner:(,thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl - Mawk 2 105
Question about @INC variable in perl 1 68
Union rows in array that have common elements 2 110
How to get all the API from website? 11 129
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question