Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

xsawyerx (8978)

xsawyerx
  (email not shown publicly)

Journal of xsawyerx (8978)

Tuesday April 28, 2009
03:29 AM

How Devel::Symdump helped Test::Ping

[ #38886 ]

While I'm working on my new simple test module (Test::Ping), my basic approach at first was "write the minimum, test it and continue from that point using TDD". Later, I figured that Net::Ping already has tests for the functionality, so if I could just port these tests to Test::Ping using its testing functions, that would basically set my tests. I started porting them.

Amongst the tests I recently ported was a Time::HiRes functionality which I did not intend to support, because I thought it would be tricky and pointless for testing anyway. However, I tried to port the test anyway and noticed that unlike other preferences, this time Net::Ping reaches for a package variable instead of an internal hash key. Weird.

I tried accessing the module's package variable through my module and failed miserably. Of course, package modules are global by package, but sometimes very late at night a memory relapse may occur, so I didn't even notice this basic mishap. Instead, I searched for Devel::* to help me find where the variable is. Devel::Symdump just showed me that the variable is $Net::Ping::hires. How simple.

This is the entire code I had to run to find that out:

perl -MNet::Ping -MDevel::Symdump -le'print Devel::Symdump->rnew("Net::Ping")->as_string;'

Truly, a great language!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.