Front page | perl.beginners |
Postings from March 2002
Re: die handler : posting again.
Thread Previous
From:
Tanton Gibbs
Date:
March 1, 2002 12:20
Subject:
Re: die handler : posting again.
Message ID:
004501c1c15e$6421ae20$f8ffa8c0@brooklyn
Ok, I actually gave this a shot, and it works...sort of.
However, the original die still prints out the first argument of the array
which is an array reference. However, you can change what die is called
with from your die_handler by calling die again, so if you just want to
print a message, I would use the technique I describe below, then create the
message inside the die handler and finally call die again from the die
handler passing the message you created.
----- Original Message -----
From: "Tanton Gibbs" <thgibbs@deltafarms.com>
To: "Sethi, Pradeep" <psethi@billpoint.com>; <ps@siteindia.com>;
<beginners@perl.org>
Sent: Friday, March 01, 2002 3:04 PM
Subject: Re: die handler : posting again.
> According to
> perldoc -f die
> and
> perldoc perlvar # look at %SIG{expr}
>
> the die_handler will be called with the string die was passed. From the
> perldoc -f die, die will concatenate all parameters together. Therefore,
> your problem makes sense. You might try passing an array reference
> containing the three strings, and then dereferencing the array from within
> your die_handler...
> i.e.
> sub die_handler {
> my(@vars) = @{ $_[0] };
> ... same as before.
> }
>
> die( ["foo", "goo", "bar"] );
>
> I didn't try this, but judging by perldoc it should work.
>
> Tanton
> ----- Original Message -----
> From: "Sethi, Pradeep" <psethi@billpoint.com>
> To: <ps@siteindia.com>; <beginners@perl.org>
> Sent: Friday, March 01, 2002 2:48 PM
> Subject: die handler : posting again.
>
>
> > I posted it earlier also but got no response. Posting again to
> > hope to get some advice.
> >
> > thanks in again
> >
> > -----Original Message-----
> >
> > Sent: Wednesday, February 27, 2002 2:46 PM
> > To: beginners@perl.org
> > Subject: die handler
> >
> >
> > Hi ,
> >
> > I have this in my code :
> >
> > local $SIG{__DIE__} = \&die_handler;
> >
> > and then
> >
> > sub die_handler {
> >
> > my (@vars)=@_;
> >
> > print STDERR "\nfirst : " . $vars[0];
> >
> > print STDERR "\nsecond : " . $vars[1];
> >
> > }
> >
> > if i give :
> >
> > die ('goo','foo','bar');
> >
> > Then I get the output :
> >
> > first : goofoobar at out.pl line 233.
> >
> > second :
> >
> > I want to have the three arguments in an array.
> >
> > can somebody tell what am I doing wrong ?
> >
> > Thanks
> >
> > Pradeep
> >
> >
> >
> > _________________________________________________________________
> > Join the world's largest e-mail service with MSN Hotmail.
> > http://www.hotmail.com
> >
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> > For additional commands, e-mail: beginners-help@perl.org
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> > For additional commands, e-mail: beginners-help@perl.org
> >
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>
Thread Previous