perl exit code

Hi - When the perl code is ran successfully I will get a return code as 0
but how can I set the perl exit code based on if condition.
What i am trying to achieve is
I wrote this below perl code to compare two dates and if $dt < $fileDate then I want to execute other perl scripts
or else i dont want to execute remaing scripts.
i found there are multiple ways that i can do this
1) write some number (say 100) to a output file if($dt < $fileDate) and read that output file and check the number if the number is 100 then i will run the remaining scripts
this process needs cretion of another file so i dont like it
2) generally if the script ran well it returns 0, so if the return code is 0 i will call other scripts
but how to fail the script if($dt > $fileDate)  I mean how to set the exit code if my condition is not met.

I want something that breaks the perl scripts if the condition is not met how can do that .


use 5.006;
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use Cwd;
use DateTime;
use DBD::mysql;
use Time::Piece;
use DBI;

my $helpme = 0;
my $man = 0;
my $fileName = 'C:\\temp\\test.txt';
my $fileDate = '';
my $dateformat = "%Y-%m-%d %H:%M:%S";
GetOptions('help' => \$helpme, 'man' => \$man, 'infile=s' => \$fileName) or pod2usage(2);

pod2usage(1) if $helpme;
pod2usage(-verbose => 2) if $man;

die "No input file name specified!" if !$fileName;

open(INFILE, "<", $fileName) || die "Could not open input file!";

my @where;
while (<INFILE>) {
    $fileDate = POSIX::strftime( "%Y-%m-%d %H:%M:%S", localtime( ( stat $fileName )[9]));
my $dt = "2015-03-18 23:28:28";
$dt = Time::Piece->strptime($dt, $dateformat);
$fileDate = Time::Piece->strptime($fileDate, $dateformat);

if($dt < $fileDate) {
    print "good" ;
else {
    print "not good" ;

close INFILE;
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use the exit function and pass the desired value as its arg.
perldoc -f exit

If the script needs to do additional processing after the if/else block, then set a var to the desired exit value and issue the exit call at a later point.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shragiAuthor Commented:
thanks FishMonger :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.