Dan's Website

Ramblings of a Disaffected Geek

 
Home > Software > Quick Perl hints
Quick Perl hints
Some quick cheat notes on Perl packaging.

Set up a PM

$ h2xs -AXn Package::Module
  • -A omits Autoloader code
  • -X omits eXternal Subroutine (e.g. C library) elements
  • -n specifies module name
To prepare archive for shipping:
$ perl Makefile.PL; make; make dist;

Writing tests

  • Remember to update use Test::More tests => 2; to number of expected tests
  • Start with a use_ok('Package::Module') test for the module
  • Then actually call use Package::Module(qw(fcn1 fcn2)); (functions required if no autoloaded fcns exist).
  • Standard test format: ok(CONDITION, DESCRIPTION) e.g. ok(do_print('hello') =~ /hello/, 'Valid output returned');
  • Execute tests with cd Package-Module && make test for basic summary or cd Package-Module/lib && perl ../t/Package-Module.t for more descriptive execution of individual test file

Use "carp" instead of "warn"

  • Gives the offending line of an error in user's file context
Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.23 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."