Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

v_thunder's scratchpad

by v_thunder (Scribe)
on Jun 14, 2004 at 10:24 UTC ( #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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-07-02 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (30 votes), past polls