Scroll to navigation

HDF(3pm) User Contributed Perl Documentation HDF(3pm)


PDL::IO::HDF - A PDL interface to the HDF4 library.


  use PDL;
  use PDL::IO::HDF;
  # Open file 'foo.hdf' with all hdf interface:
  my $HDF = PDL::IO::HDF->new("foo.hdf");
  # You can call functions from either the SD or VS interfaces:
  # To close the file:


This library provides functions to manipulate HDF files with the SD, VS, and V HDF interfaces.

For more information on HDF, see

The 'new' function of this package uses the 'new' functions for the individual HDF interfaces. This allows you to use all of the interfaces at one time (if you don't mind the extended syntax).

Actually using the HDF files comes down to using one of the particular interfaces, for that see the docs on those modules.


These constants are now implemented using the perl 'use constant' pragma.

Previously, they were just scalars that were changeable (which is a no-no).

See constant(1) for more info on how to use these in your code.

Access Modes

Open the file in read-only mode.
Open the file in write-only mode.
Clobber the file (create it if it doesn't exist, and then open with RW mode).
Open the file in read-write mode.
Open the file in read-write mode.

VS Interface Interlacing Modes

HDF4 Data Type Codes:

HDF's unsigned char ~= PDL's byte
HDF's char ~= PDL's byte
HDF's 32-bit float ~= PDL's float
HDF's 64-bit float ~= PDL's double
HDF's 8-bit integer ~= PDL's byte
HDF's 8-bit unsigned integer ~= PDL's byte
HDF's 16-bit integer ~= PDL's short
HDF's 16-bit unsigned integer ~= PDL's ushort
HDF's 32-bit integer ~= PDL's long
HDF's 32-bit integer ~= PDL's long

Misc. HDF Library Constants:

This is the max name length for SDS variables, attribtues, and just about anything else.
This is the max number of dims a HDF variable can have.
Max length of V interface names.


Judd Taylor, Orbital Systems, Ltd. judd dot t at orbitalsystems dot com


Patrick Leilde contribs of Olivier Archer


perl(1), PDL(1), PDL::IO::HDF::SD(1), PDL::IO::HDF::VS(1), constant(1).

2022-10-26 perl v5.36.0