in reply to Re: Re: Re: Context aware functions - best practices?
in thread Context aware functions - best practices?
However this is still not an exhaustive check as it will fail if some moron doesUNIVERSAL::isa($array_ref,"ARRAY") or die "Can't use anything but an array";
Which is a case where afaik only perl itself can tell the difference.my $array_ref=bless {},"ARRAY";
The third option is I guess the most paranoid and would be something like:
So personally I would just let my code choke and have the end user track the problem down. (This assumes that I have already sufficient regression test to ensure that my code is not in error in the first place ;-)eval{ ref($arrayref) and @$arrayref ? 1 : 1 } or die "Must have a reference to something that behaves like an ARRA +Y.\n". "Failed to coerce '$arrayref': $@";
--- demerphq
my friends call me, usually because I'm late....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Context aware functions - best practices?
by MarkM (Curate) on Jan 16, 2003 at 20:18 UTC | |
by demerphq (Chancellor) on Jan 16, 2003 at 20:39 UTC | |
|
Re: Re: Re: Re: Re: Context aware functions - best practices?
by BrowserUk (Patriarch) on Jan 16, 2003 at 20:39 UTC | |
by demerphq (Chancellor) on Jan 17, 2003 at 12:39 UTC |