Hi, Edward,

You can test for PDLness with "UNIVERSAL::isa($foo,'PDL')", but that's  
a bit awkward.  I generally test with "ref($foo) eq 'PDL'", but that  
will break if someone hands you a PDL subclass.

For most stuff, you can just check definedness.

Cheers,
Craig


On Jul 1, 2008, at 5:19 PM, Edward (Post Doc) Hyer wrote:

> With regular Perl subroutines, doing simple things, my habit had been
> for them to simply
> return;
> if something went wrong. This meant I could simply check whether the
> output was defined to determine of the routine had done its job, as is
> standard Perl SOP.
>
> With routines that are supposed to return PDLs, this is trickier.
>
> Basically, I'm having trouble finding a routine that I can use to sort
> PDLs and other output. If I test the output, it barfs "multielement
> piddle in conditional expression" if it gets a PDL. If I used nelem(),
> well, nelem(undef) == 1.
>
> TMTOWTDY, but the other ways are definitely uphill from a simple  
> ispdl()
> function that can test for PDLness. I can't believe there's no such
> function-- there must be!
>
> Help me out,
>
> --EJH.
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to