1UDUNITSPerl(1)                 UNIDATA UTILITIES                UDUNITSPerl(1)
2
3
4

NAME

6       udunitsperl - perl extension for UDUNITS
7

SYNOPSIS

9       use UDUNITS;
10
11       UDUNITS::init($path)
12
13       $unit = UDUNITS::new()
14       $unit = UDUNITS::scan($spec)
15       $unit2 = UDUNITS::dup($unit)
16
17       $unit->hasorigin()
18       $unit->istime()
19       $unit->clear()
20       $unit->invert()
21       $unit->shift($amount)
22       $unit->scale($factor)
23       $unit->raise($power)
24       $unit->multiply($unit2)
25       $unit->divide($unit2)
26       $unit->convert($unit2, $slope, $intercept)
27
28       $unit2 = $unit->dup()
29       $spec = $unit->print()
30
31       $timeunit->valtocal($value, $year, $month, $day, $hour, $minute, $second)
32       $value = $timeunit->caltoval($year, $month, $day, $hour, $minute, $second)
33
34       UDUNITS::term()
35

DESCRIPTION

37       UDUNITSPerl  is  a  port of the udunits(3) library into a native Perl 5
38       extension.
39
40   PACKAGE FUNCTIONS
41       The functions in the UDUNITS package should be invoked by  use  of  the
42       UDUNITS:: prefix (e.g. UDUNITS::scan() invokes the scan() function).
43
44       init($path)
45           Initializes  the  UDUNITS module.  File $path is the units database
46           to be read.  If $path is the empty string, then the  default  data‐
47           base  is  read.  The default database is determined at the time the
48           UDUNITS package is installed.
49
50       new()
51           Returns a trivial unit object.  A trivial unit object is dimension‐
52           less and has the value 1.
53
54       scan($spec)
55           Returns  a  unit  object determined by the string $spec or an unde‐
56           fined perl scalar if the UDUNITS module hasn't been initialized  or
57           the units specification is invalid.
58
59       dup($unit)
60           Returns a duplicate of unit object $unit.  This action is identical
61           to invoking the dup()  member  function  of  a  unit  object  (e.g.
62           $unit->dup()).
63
64       term()
65           Terminates use of the UDUNITS module.  Frees allocated resources.
66
67   MEMBER FUNCTIONS
68       Every  unit  object  created by one of the above functions has a set of
69       method functions.  A member function is invoked by using the  unit  ob‐
70       ject  as  a reference (e.g. $unit->invert() invokes the invert() member
71       function of unit object $unit).
72
73       hasorigin()
74              Returns true if the unit has an origin  (possibly  set  via  the
75              shift() member function) and false otherwise.
76
77       istime()
78              Returns  true  if  the  unit  is a pure unit of time (e.g. "sec‐
79              onds").
80
81       clear()
82              Clears the unit object by setting it to the trivial unit object.
83
84       invert()
85              Inverts the unit object (e.g. "seconds" becomes "1/seconds").
86
87       shift($amount)
88              Shifts the origin of the unit object by the amount $amount.
89
90       scale($factor)
91              Scales the unit object by the amount $factor.
92
93       raise($power)
94              Raises the unit object by the power $power.
95
96       multiply($unit2)
97              Multiplies the unit object by the unit $unit2.
98
99       divide($unit2)
100              Divides the unit object by the unit $unit2.
101
102       convert($unit2,$slope,$intercept)
103              Computes the slope and intercept necessary to convert values  in
104              units of the unit object into values in units of unit2.  Returns
105              0 on success, UDUNITS::ENOINIT if the units module  hasn't  been
106              initialized,  and  UDUNITS::ECONVERT if the unit objects are not
107              convertable.
108
109       dup()  Returns a duplicate of unit object.  This action is identical to
110              invoking the UDUNITS::dup($unit) package function.
111
112       print()
113              Returns  the  canonical  string specification of the unit object
114              (e.g. "kilogram meter second-2").
115
116       valtocal($value, $year, $month, $day, $hour, $minute, $second)
117              Breaks down the value $value in units of the  unit  object  into
118              UTC  calendar  time.  Returns 0 on success, UDUNITS::EINVALID if
119              the unit object is not a unit of time, and UDUNITS::ENOINIT  the
120              units  module hasn't been initialized.  The returned $second ar‐
121              gument is floating-point.
122
123       caltoval($year, $month, $day, $hour, $minute, $second)
124              Returns the value in units of the unit object  that  corresponds
125              to the given UTC calendar time or a perl undefined scalar if the
126              units module hasn't been initialized or the unit object is not a
127              unit  of time.  If defined, then the returned value is floating-
128              point.  The $second argument may be floating-point.
129
130       In addition to the above functions, most C macro constants that are de‐
131       fined in the UDUNITS header file udunits.h are also available to a perl
132       script by dropping any `UT_' substring and using the UDUNITS::  prefix,
133       e.g. UDUNITS::EINVALID.
134

SEE ALSO

136       perl(1), udunits(3)
137
138
139
140Printed: 119-6-22        $Date: 2003/04/29 15:57:37 $           UDUNITSPerl(1)
Impressum