Object creation failure in perl

  • Thread starter ramesh.thangamani
  • Start date
R

ramesh.thangamani

I have written a code like this in my module:

my $obj = MyModule->new() or die "Failed to create object of type
MyModule $!" in my code. Strangely enough sometimes the object
creation is failing and I am not sure what could really be the issue.
This script is running on Modperl and the platform is linux.
Appreciate any help on this

Thanks,
Ramesh
 
A

anno4000

I have written a code like this in my module:
^
"Code" in the sense of "computer instructions" is a mass noun and
doesn't take an indefinite article.
my $obj = MyModule->new() or die "Failed to create object of type
MyModule $!" in my code.

Presumably this code is part of the script that *uses* your module,
not part of the module itself.
Strangely enough sometimes the object
creation is failing and I am not sure what could really be the issue.
This script is running on Modperl and the platform is linux.
Appreciate any help on this

You need to give us a little more than that if you want help. What
does your ->new do? We can't debug code we don't see, show it.

Anno
 
M

Michele Dondi

my $obj = MyModule->new() or die "Failed to create object of type
MyModule $!" in my code. Strangely enough sometimes the object

As a side note, most likely $! is not what you want: I'm not saying it
isn't. I'm saying it is improbable to be.


Michele
 
R

ramesh.thangamani

^
"Code" in the sense of "computer instructions" is a mass noun and
doesn't take an indefinite article.


Presumably this code is part of the script that *uses* your module,
not part of the module itself.


You need to give us a little more than that if you want help. What
does your ->new do? We can't debug code we don't see, show it.

Anno

I am just creating an instance of MyModule that's it.
 
A

anno4000

written a code like this in my module:

I am just creating an instance of MyModule that's it.

Yes, and for that you call MyModule->new and you haven't told us what
that method does. How, do you expect, can anyone tell you why it
occasionally fails? This is ridiculous.

Anno
 
P

Paul Lalli

I have written a code like this in my module:

my $obj = MyModule->new() or die "Failed to create object of type
MyModule $!" in my code. Strangely enough sometimes the object
creation is failing and I am not sure what could really be the issue.

The issue is pretty clearly that you did something wrong in your new()
method. Since you haven't shown us your new() method, there is no
possible way anyone can tell you exactly what it is that you did
wrong.

Paul Lalli
 
R

ramesh.thangamani

The issue is pretty clearly that you did something wrong in your new()
method. Since you haven't shown us your new() method, there is no
possible way anyone can tell you exactly what it is that you did
wrong.

Paul Lalli

The thing here is the code is not failing always. I am using a cron
wrapper script which creates an object of a module, then runs a
reports and emails it. The problem is it is failing only rarely like
for eg once in a month. The script runs daily.

I just wanted to know when we experience object creation failure.

1. One thing is the system runs out of RAM, but it is very very
remote scenario.
2. May be when the cron is running there is something which causing
the failure in middle ?
3. Or something wrong in the code ?.

It is really a simple object creation code, which is failing only some
cases. There is nothing wrong in the code also since the same code
runs fine most of the cases.
 
P

Paul Lalli

The thing here is the code is not failing always.

That is not an important "thing". It is failing. Therefore, you did
something wrong.
I am using a cron wrapper script

Also irrelevant.
which creates an object of a module, then runs a
reports and emails it. The problem is it is failing only rarely like
for eg once in a month. The script runs daily.

More irrelevance.
I just wanted to know when we experience object creation failure.

"We" don't. You are. And you're experiencing it because YOU'VE DONE
SOMETHING WRONG. We have no way of knowing WHAT that something is.
1. One thing is the system runs out of RAM, but it is very very
remote scenario.
2. May be when the cron is running there is something which causing
the failure in middle ?
3. Or something wrong in the code ?.

It is really a simple object creation code, which is failing only some
cases. There is nothing wrong in the code also since the same code
runs fine most of the cases.

BULL COCKY. If there was nothing wrong with the code, it would always
work.

Let me explain to you what you've just done. You've called your
mechanic and said "my car sometimes doesn't work." The mechanic has
told you to bring it in to his shop so he can look at it, and you've
said "no, it only sometimes doesn't work". The mechanic has asked you
what you mean by "doesn't work", and you've responded that you just
want him to give you a list of every possible thing that could be
wrong with the roads, traffic lights, stop signs, and Motor Vehicle
Department that would make your car not work sometimes, because you're
sure there's nothing at all wrong with your car.

You've used up your coupons. Good luck to you.

Paul Lalli
 
M

Michele Dondi

The thing here is the code is not failing always. I am using a cron

It can happen. Clearly, it will fail upon a condition. Without seeing
the code, or (preferably) a minimal version of it, it's hard to say.
wrapper script which creates an object of a module, then runs a
reports and emails it. The problem is it is failing only rarely like

This is hardly relevant except possibly for permission issues: which
have nothing to do with the fact that the code is an object creation
one.
for eg once in a month. The script runs daily.

I just wanted to know when we experience object creation failure.

In just so many situations that one can't really give you a proper
answer. The code that takes care of object creation can do quite about
anything, so the only proper answer to your actual question thus far
can only be: quite about anything.
1. One thing is the system runs out of RAM, but it is very very
remote scenario.

Yes, it can be. Hard to say without seeing the actual code. How 'bout
logging memory usage anyway, if you have this suspect?
2. May be when the cron is running there is something which causing
the failure in middle ?

In the middle of... what?
3. Or something wrong in the code ?.

May be. Once again: hard to say without seeing the actual code.
It is really a simple object creation code, which is failing only some
cases. There is nothing wrong in the code also since the same code

This claim of yours is in contradiction with possibility 3 above.
runs fine most of the cases.

"running fine most of the cases" generally is not regarded as a good
proof of "there not being anything wrong in the code." Perhaps you
mean that it is syntactically correct, and that may well be. A whole
another story...


Michele
 
J

Jim Cochrane

That is not an important "thing". It is failing. Therefore, you did
something wrong.

Not only that, but the fact that it is only sometimes failing makes the
problem worse. If it always failed in the same manner, finding and
fixing the problem is likely to be much easier than in your case, where
it only fails sometimes. Can you (OP) see why?

It's hard enough to fix an intermittent problem when you have access to
the code. You're asking people to help you find and fix the problem
without the code. Demanding the impossible, I'd say.


--
 
M

Mark Clements

Paul said:
That is not an important "thing". It is failing. Therefore, you did
something wrong.


Also irrelevant.
Notwithstanding the remainder of this post, the fact that something runs
from cron can be relevant, since a process running from cron tends to
have very few environment variables set by default and the user's shell
startup script(s) isn't run.

Mark
 
R

ramesh.thangamani

The thing here is the code is not failing always. I am using a cron

It can happen. Clearly, it will fail upon a condition. Without seeing
the code, or (preferably) a minimal version of it, it's hard to say.
wrapper script which creates an object of a module, then runs a
reports and emails it. The problem is it is failing only rarely like

This is hardly relevant except possibly for permission issues: which
have nothing to do with the fact that the code is an object creation
one.
for eg once in a month. The script runs daily.
I just wanted to know when we experience object creation failure.

In just so many situations that one can't really give you a proper
answer. The code that takes care of object creation can do quite about
anything, so the only proper answer to your actual question thus far
can only be: quite about anything.
1. One thing is the system runs out of RAM, but it is very very
remote scenario.

Yes, it can be. Hard to say without seeing the actual code. How 'bout
logging memory usage anyway, if you have this suspect?
2. May be when the cron is running there is something which causing
the failure in middle ?

In the middle of... what?
3. Or something wrong in the code ?.

May be. Once again: hard to say without seeing the actual code.
It is really a simple object creation code, which is failing only some
cases. There is nothing wrong in the code also since the same code

This claim of yours is in contradiction with possibility 3 above.
runs fine most of the cases.

"running fine most of the cases" generally is not regarded as a good
proof of "there not being anything wrong in the code." Perhaps you
mean that it is syntactically correct, and that may well be. A whole
another story...

Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Cool people. Thanks for you responses sorry for troubling you ( I
thought i can get some common cases). I will check in my code more and
if I am unable to debug more I will try to post a similar code. The
problem is it is a code which I can't post here.
 
M

Michele Dondi

Cool people. Thanks for you responses sorry for troubling you ( I
thought i can get some common cases). I will check in my code more and
if I am unable to debug more I will try to post a similar code. The
problem is it is a code which I can't post here.

This is a common situation, and nobody asks you to post the actual
code. Probably it contains too much irrelevant stuff too, for people
to want to read it in detail. Prepare a minimal example removing stuff
step by step as long as the problem persists (this may actually be
slightly more difficult to do in your case than in other ones, due to
the nature of the problem) and chances are that you may even find the
solution yourself in the course of doing so.


Michele
 

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

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,216
Latest member
DarrelLho

Latest Threads

Top