This tutorial assumes that the make program that Perl is configured to
use is called C<make>. Instead of running "make" in the examples that
follow, you may have to substitute whatever make program Perl has been
-configured to use. Running "perl -V:make" should tell you what it is.
+configured to use. Running B<perl -V:make> should tell you what it is.
=head2 Version caveat
package Mytest;
use strict;
+ use warnings;
require Exporter;
require DynaLoader;
If you are on a Win32 system, and the build process fails with linker
errors for functions in the C library, check if your Perl is configured
-to use PerlCRT (running "perl -V:libc" should show you if this is the
+to use PerlCRT (running B<perl -V:libc> should show you if this is the
case). If Perl is configured to use PerlCRT, you have to make sure
PerlCRT.lib is copied to the same location that msvcrt.lib lives in,
so that the compiler can find it on its own. msvcrt.lib is usually
that looks like this:
#! /opt/perl5/bin/perl
-
+
use ExtUtils::testlib;
-
+
use Mytest;
-
+
Mytest::hello();
Now we make the script executable (C<chmod -x hello>), run the script
In general, it's not a good idea to write extensions that modify their input
parameters, as in Example 3. Instead, you should probably return multiple
values in an array and let the caller handle them (we'll do this in a later
-example). However, in order to better accomodate calling pre-existing C
+example). However, in order to better accommodate calling pre-existing C
routines, which often do modify their input parameters, this behavior is
tolerated.
#include <stdlib.h>
#include "./mylib.h"
-
+
double
foo(int a, long b, const char *c)
{
or easier to understand. These routines should live in the .pm file.
Whether they are automatically loaded when the extension itself is loaded
or only loaded when called depends on where in the .pm file the subroutine
-definition is placed. You can also consult L<Autoloader> for an alternate
+definition is placed. You can also consult L<AutoLoader> for an alternate
way to store and load your extra subroutines.
=head2 Documenting your Extension