[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

perl end block alternative

I am using older version of perl in my work, we don't want to upgarde to newer version of perl anytime soon, because that might break lot of things, but I want to do something like

end {

   call subroutine;
}

we are using perl 5.0, when I use end{} it compiles ok, but doesn't seem to run the end block. Meaning never executes anything from end block.

Is there an alternative for this end{} block?

Thanks
0
Anu2117
Asked:
Anu2117
  • 4
  • 4
1 Solution
 
TintinCommented:
I very seriously doubt if you are using Perl 5.0

perl -v

will tell you the exact version.

Perl is case sensitive, so 'end' should be 'END'

0
 
Anu2117Author Commented:

END {
    print "; Anu: Lunit end block\n";
    $ludb->write_persistant_objects();
};
 
I know the syntax, and it works on 5.8.5 the lastest, I have.
 
but it doesn't work on 5.0
 
0
 
TintinCommented:
Can you please tell us the *exact* perl version you have (5.0 is not a valid Perl version).

Post the output of

perl -v
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Anu2117Author Commented:
/usr/97r1.3/lib/perl5/i386_linux22/5.00404
0
 
Anu2117Author Commented:
This is not running plain perl code, I am running a tool which uses perl 5.00404 version apparently.  
0
 
TintinCommented:
What about a very, very simple piece of code like below.  Does it run under your old Perl version?
END {
  print "This is the end block\n";
}
 
print "Start\n";

Open in new window

0
 
Anu2117Author Commented:
It doesn't like init{ }, check { },... as well.
Instead of getting end{ } to work, is there another way of achieving the same result in perl?
0
 
TintinCommented:
Are you saying the output you get from the script I posted is just

Start

and nothing else?

Do you have a specific need for an END block?  Could you not just put the code at the end of your script instead?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now