Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I write a new sub in a git cloned CPAN module and test it by bypassing the Original Module

by kcott (Archbishop)
on Dec 20, 2016 at 19:10 UTC ( [id://1178237]=note: print w/replies, xml ) Need Help??


in reply to How do I write a new sub in a git cloned CPAN module and test it bypassing the Original Module

G'day yysachinyy,

Welcome to the Monastery.

"I tried setting PERL5LIB and use lib pragma ... but din't help." [sic]

You don't show exactly what you did: here's some pointers.

  • PERL5LIB needs to be set before you call your scripts and made available to them (e.g. via export).
  • use lib should be used before use DateTime; be careful of relative paths.
  • Check that @INC has the path you set: consider doing so in a CHECK or INIT block.
  • Are you running in "taint mode"? See -T and -t in perlrun. See perlsec and, in particular, the "Taint mode and @INC" section.
  • Are you using the warnings pragma?
"I would like to know how Perl gurus/monks solve and contribute to CPAN Module."

My basic process would be as follows. I'll reference the current DateTime module; however, this would be what I'd generally use for any module. You may have different methods for achieving each step — I'm certainly not trying to recommend you use different tools — but the order of steps should be much the same. And, of course, the commands I've used are just examples.

  1. Set up a work area.
    $ cd /some/base/work/dir $ mkdir DateTime $ cd DateTime
  2. Get the currrent distribution.
    $ wget http://search.cpan.org/CPAN/authors/id/D/DR/DROLSKY/DateTime-1. +41.tar.gz $ tar zxvf DateTime-1.41.tar.gz > DateTime-1.41.INSTALL 2>&1 $ view DateTime-1.41.INSTALL # Check there's no errors $ cd DateTime-1.41
  3. Read any relevant documentation.
    $ view README # That's "README.md" for this distro $ view INSTALL
  4. Modify the module code.
    $ cd lib $ vi DateTime.pm
  5. Write new test(s).
    $ cd ../t $ vi new_test.t
  6. Create Makefile, build and test.
    $ cd .. $ perl Makefile.PL $ make $ make test
  7. Repeat the last three steps until the code does what you want and the tests all pass.
    $ make realclean $ # ... repeat commands already shown ...

See also: "PAUSE: The [Perl programming] Authors Upload Server".

— Ken

Replies are listed 'Best First'.
Re^2: How do I write a new sub in a git cloned CPAN module and test it by bypassing the Original Module
by yysachinyy (Novice) on Dec 21, 2016 at 02:17 UTC
    Thanks Ken.

    This is what I am exactly looking for. I will try out.

    thank you. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1178237]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found