I start creating Perl-modules wit h2xs. Real XS-modules (C to Perl) and non-XS (I use it also for pure Perl modules to get the skeleton) ones.
For me it is annoying that h2xs assumes the current used version of Perl to be required (in Makefile.PL and also in the modules .pm).
If I transfer the module to some other machine with an older version of Perl I need to modify 1 or 2 files.
Is there a way to manually set the required Perl-version in h2xs or in the Makefile.PL??
Thanks for help!
Are you looking for the -b
option? From the docs:
-b, --compat-version=version
Generates a .pm file which is backwards compatible with the specified perl version.
For versions < 5.6.0, the changes are. - no use of 'our' (uses 'use vars' instead) - no 'use warnings'
Specifying a compatibility version higher than the version of perl you are using to run h2xs will have no effect. If unspecified h2xs will default to compatibility with the version of perl you are using to run h2xs.
Seems to work as expected:
$ h2xs -b 5.10.0 -A Foo
Writing Foo/ppport.h
Writing Foo/lib/Foo.pm
Writing Foo/Foo.xs
Writing Foo/Makefile.PL
Writing Foo/README
Writing Foo/t/Foo.t
Writing Foo/Changes
Writing Foo/MANIFEST
$ grep 'use 5' Foo/lib/Foo.pm
use 5.010000;
$ rm -rf Foo/
$ h2xs -b 5.20.0 -A Foo
Writing Foo/ppport.h
Writing Foo/lib/Foo.pm
Writing Foo/Foo.xs
Writing Foo/Makefile.PL
Writing Foo/README
Writing Foo/t/Foo.t
Writing Foo/Changes
Writing Foo/MANIFEST
$ grep 'use 5' Foo/lib/Foo.pm
use 5.020000;