Avatar of beer9
beer9
Flag for India asked on

Why do we return 1 in the perl script?

In the perl script I have seen the last line of the code is usually '1;' I would like to know why it is like that. Incase I run this script from the bash then bash expect '0' if command successfully executed.
Perl

Avatar of undefined
Last Comment
beer9

8/22/2022 - Mon
tel2

I'm not sure of the reasoning, but I believe perl "modules" need to do that, so they will work.
Are you talking about modules (extension .pm) or scripts?
ASKER CERTIFIED SOLUTION
Minh Võ Công

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
tumtum73

I'm not sure I agree that you "should" return a 1.  I have always been taught to return a zero to indicate a successful run.  Where are you being told to return a 1, is it a specific module or function?
Ferrosti

You mix up "1;" at the end of a perl script and "return 1;".
Your can find a good explanation for it here:
http://lists.netisland.net/archives/phlpm/phlpm-2001/msg00426.html
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ozo

I think you meant mix up "1;" with "exit 1;"
Ferrosti

ozo, you are right :) It's been a tough day at work today :)
beer9

ASKER
Thank  you! :-)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.