Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

v_thunder's scratchpad

by v_thunder (Scribe)
on Jun 14, 2004 at 10:24 UTC ( [id://366469]=scratchpad: print w/replies, xml ) Need Help??

#!/usr/bin/perl -w package Foo; sub load { my $class = shift; my $self = bless {}, $class; eval { $self->reload (@_); die "LA LA LA"; }; if (my $e = $@) { print "FOO1: $e"; die $e; } return $self; } sub reload { my $self = shift; die "reload: Options must be name => value pairs" if (@_ % 2); my $opts = { @_ }; # Make sure we have a brand-new cache dir die "lalalala"; return $self; } sub DESTROY { my $self = shift; $self->destroy_cache_dir; } sub destroy_cache_dir { my $self = shift; eval { # nothing }; if (my $e = $@) { # We don't want to die if run_cmd fails print "FOO2: $e"; } delete $self->{cache}; } package FooBar; sub load_guess { my $class = shift; die "load_guess: Options must be name => value pairs" if (@_ % 2); my $opts = { @_ }; # require Foo; my $jail; eval { $jail = Foo->load (%$opts); }; if (my $e = $@) { print "FOOBAR: $e"; } unless ($jail) { print "Jail is undef!\n"; } return $jail; } package main; FooBar->load_guess (path => "asdf"); exit 0; __END__
http://perlmonks.org/index.pl?node_id=192255
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found