Pete Ratzlaff > Astro-FITS-CFITSIO-1.10 > examples/match_datatype.pl

Download:
Astro-FITS-CFITSIO-1.10.tar.gz

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Source  

match_datatype( ) ^

        $cfitsio_type = match_datatype($piddle);
        $cfitsio_type = match_datatype(long); # or short, or float, etc.

PDL datatypes are always guaranteed to be the same size on all architectures, whereas CFITSIO datatypes (TLONG, for example), will vary on some architectures since they correspond to the C datatypes on that system. This poses a problem for Perl scripts which wish to read FITS data into piddles, and do so in a portable manner. This routine takes a PDL object or PDL::Types token (returned by float() and friends when given no arguments), and returns the same-sized CFITSIO datatype, suitable for passing to routines such as fits_read_col().

syntax highlighting: