Skip to Main Content
Perl in a Nutshell, 2nd Edition
book

Perl in a Nutshell, 2nd Edition

by Nathan Patwardhan, Ellen Siever, Stephen Spainhour
June 2002
Beginner content levelBeginner
759 pages
80h 42m
English
O'Reilly Media, Inc.
Content preview from Perl in a Nutshell, 2nd Edition

ExtUtils::Constant

Generates XS code to import C header constants, allowing Perl modules to AUTOLOAD constants defined in C library header files. Generally, you should not touch ExtUtils::Constant functions, since they are already implemented by h2xs.

For example:

use ExtUtils::Constant qw (WriteConstants);
WriteConstants(
    NAME => `Nate',
    NAMES => [qw(Nate Nathan Nathaniel)], # not Nat
);
# Generates wrapper code to make the values of the constants
# Nate Nathan Nathaniel available to perl

Currently, this module understands the following types, although h2xs may only know a subset. The sizes of the numeric types are chosen by the Configure script at compile time.

IV

Signed integer. At least 32 bits.

UV

Unsigned integer. The same size as IV.

NV

Floating-point type. Probably double. Possibly long double.

PV NUL[L]

Terminated string. Length will be determined with strlen.

PVN

A fixed-length thing, given as a pointer, length pair. If you know the length of a string at compile time, you can use this instead of PV.

SV

A mortal SV.

YES

Truth (PL_sv_yes). The value is not needed (and is ignored).

NO

Defined falsehood (PL_sv_no). The value is not needed (and is ignored).

UNDEF

The value of the macro is not needed.

ExtUtils::Constant implements the following functions.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl by Example, Fourth Edition

Perl by Example, Fourth Edition

Ellie Quigley
Perl Cookbook, 2nd Edition

Perl Cookbook, 2nd Edition

Tom Christiansen, Nathan Torkington
Perl in a Nutshell

Perl in a Nutshell

Nathan Patwardhan, Ellen Siever, Stephen Spainhour
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 0596002416Errata Page