develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Why $@ makes me cry

Thread Previous | Thread Next
From:
Ben Morrow
Date:
June 26, 2008 07:18
Subject:
Re: Why $@ makes me cry
Message ID:
mikcj5-2pf1.ln1@osiris.mauzo.dyndns.org

Quoth davem@iabyn.com (Dave Mitchell):
> On Thu, Jun 26, 2008 at 02:16:59PM +0200, Aristotle Pagaltzis wrote:
> > Even so, I don’t see any easy way around *all* the problems, like
> > $@ getting cleared as a side-effect of checking it for truth.
> 
> How can that happen?
> (I clearly haven't been paying close enough attention this thread :-( )

#!/usr/bin/perl -l

use warnings;
use strict;

{
    package OverKill;

    use overload '""' => sub { eval { 1 }; 'Oh noes!'; };
}

eval { die bless [], 'OverKill' };
if ($@) {
    print $@ ? $@ : '<gone>';
}

__END__

Ben

-- 
I touch the fire and it freezes me,                      [ben@morrow.me.uk]
I look into it and it's black.
Why can't I feel? My skin should crack and peel---
I want the fire back...                     BtVS, 'Once More With Feeling'

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About