10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.7 Perl BindingPerl 1 supports a mechanism for extending the language interpreter via native C libraries.The PDFlib wrapper for Perl consists of a C wrapper file and a Perl package module.The C module is used to build a shared library which the Perl interpreter loads at runtime,with some help from the package file. Perl scripts refer to the shared library modulevia a use statement.Installing the PDFlib Perl Edition. The Perl extension mechanism loads shared librariesat runtime through the DynaLoader module. The Perl executable must have been compiledwith support for shared libraries (this is true for the majority of Perl configurations).For the PDFlib binding to work, the Perl interpreter must access the PDFlib Perl wrapperand the module file pdflib_pl.pm. In addition to the platform-specific methods describedbelow you can add a directory to Perl’s @INC module search path using the -Icommand line option:perl -I/path/to/pdflib hello.plUnix. Perl will search both pdflib_pl.so (on Mac OS X: pdflib_pl.dylib) and pdflib_pl.pm inthe current directory, or the directory printed by the following Perl command:perl -e 'use Config; print $Config{sitearchexp};'Perl will also search the subdirectory auto/pdflib_pl. Typical output of the above commandlooks like/usr/lib/perl5/site_perl/5.8/i686-linuxWindows. PDFlib supports the ActiveState port of Perl 5 to Windows, also known asActivePerl. 2 Both pdflib_pl.dll and pdflib_pl.pm will be searched in the current directory,or the directory printed by the following Perl command:perl -e "use Config; print $Config{sitearchexp};"Typical output of the above command looks likeC:\Program Files\Perl5.8\site\libError Handling in Perl. The Perl binding installs a special error handler which translatesPDFlib errors to native Perl exceptions. The Perl exceptions can be dealt with by applyingthe appropriate language constructs, i.e., by bracketing critical sections:eval {...some PDFlib instructions...};die "Exception caught" if $@;1. See www.perl.com2. See www.activestate.com2.7 Perl Binding 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!