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
Solved

how to use exit?

Posted on 2000-04-24
7
221 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
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
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.

 
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 Scripting from a shell script with if and for 4 87
perl to convert excel to csv 3 253
Log File Creation with Header and Footer 17 127
perl syntax 3 16
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

860 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