Perl equivalent of "On error resume"

R

Rajesh

Hi,

Can anybody tell me if there is any equivalent of "On error resume" in
Perl? If not, how can u implemnt it?
 
M

Martien Verbruggen

Hi,

Can anybody tell me if there is any equivalent of "On error resume" in
Perl?

I think you probably want eval BLOCK, which can be used to trap
exceptions.

$ perldoc -f eval

But there is not enough context in your question to be certain. Where
does this "On error resume" thing come from (Visual Basic or so?),
what does it do, and, more importantly, what do _you_ want to use it
for?
If not, how can u implemnt it?

I don't know how 'u' can implement it, since I don't know 'u'.

Martien
 
U

Uri Guttman

R" == Rajesh said:
Can anybody tell me if there is any equivalent of "On error resume" in
Perl? If not, how can u implemnt it?

it would help if you explained that did in whatever language it came
from.

uri
 
R

Rajesh

Uri Guttman said:
it would help if you explained that did in whatever language it came
from.

uri

Ok...now, I am a newbie to perl. Actually i was working on a script to
export the details of a registry to a file. It was working well but it
stops sometimes with the error,
Can't call method "GetValues" on an undefined value at CompReg.pm line
239.

I figured out the reason for the error which is that i dont have
enough permissions to read a particular registry key. So, the program
stops when it reaches the key. I want it to continue and ignore if it
encounters any key which i dont have any permissions. How to implement
that?

In Visual Basic, there is "On error resume" which will continue the
program if it encounters any error. I wanted to know if there is any
equivalent

Rajesh
 
T

Thomas Kratz

Rajesh said:
Ok...now, I am a newbie to perl. Actually i was working on a script to
export the details of a registry to a file. It was working well but it
stops sometimes with the error,
Can't call method "GetValues" on an undefined value at CompReg.pm line
239.

Perhaps you could check with

$val = $thingy->GetValues if defined($thingy); # not real code

before you try to call a method on it?
I figured out the reason for the error which is that i dont have
enough permissions to read a particular registry key. So, the program
stops when it reaches the key. I want it to continue and ignore if it
encounters any key which i dont have any permissions. How to implement
that?

In Visual Basic, there is "On error resume" which will continue the
program if it encounters any error. I wanted to know if there is any
equivalent

perldoc -f eval

Thomas
 
T

Tad McClellan

Rajesh said:
So, the program
stops when it reaches the key. I want it to continue and ignore if it
encounters any key which i dont have any permissions. How to implement
that?


perldoc -f eval


The "eval BLOCK" form is the usual way of dealing with exceptions.
 
B

Bart Lateur

Rajesh said:
Can't call method "GetValues" on an undefined value at CompReg.pm line
239.

I figured out the reason for the error which is that i dont have
enough permissions to read a particular registry key. So, the program
stops when it reaches the key. I want it to continue and ignore if it
encounters any key which i dont have any permissions. How to implement
that?

Why not check if you indeed have an object before trying to call the
method?

$regObj->GetValues if $regObj;
 
R

Rajesh

$val = $thingy->GetValues if defined($thingy); # not real code

before you try to call a method on it?


Thanks a lot. Actually i didnt know how to check if the object exists or not.
That surely helped.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top