Solved

perl end block alternative

Posted on 2008-10-06
8
452 Views
Last Modified: 2012-05-05
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
Comment
Question by:Anu2117
  • 4
  • 4
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 22654210
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
 

Author Comment

by:Anu2117
ID: 22654252

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
 
LVL 48

Expert Comment

by:Tintin
ID: 22654345
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
 

Author Comment

by:Anu2117
ID: 22654659
/usr/97r1.3/lib/perl5/i386_linux22/5.00404
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Anu2117
ID: 22654729
This is not running plain perl code, I am running a tool which uses perl 5.00404 version apparently.  
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22655189
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
 

Author Comment

by:Anu2117
ID: 22661731
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
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 22662873
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now