User since: Jun 18, 2004 at 22:29 UTC (19 years ago)
Last here: Oct 05, 2017 at 19:44 UTC (5 years ago)
Experience: 319
Level:Scribe (6)
Writeups: 45
Location:Northern Virginia
User's localtime: Apr 02, 2023 at 01:33 EDT
Scratchpad: View
For this user:Search nodes

Posts by KeighleHawk
perlcritic compliant way to eval? in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by KeighleHawk
on Jul 20, 2016 at 13:28

    So I've done a bad thing (TM) I am certain. I wanted to easiliy create a slew of "data files" from exisiting code that could be read back in and executed and later allow us to add many, many more test files. So I opted to use Data::Dumper to create the initial files, fixed them up a bit, then used the following to set the needed values for each test:

    { no strict 'vars'; local $/; my $in; open $in, '<', $test_env or die "..."; my $rc = eval <$in>; close $in; # set various values from that data structure. };

    The above is essentially in a loop, reading in each test data file.

    Besides the obvious of redesigning the data files as XML or some other, is there anyway to accomplish the above in a way that perlcritic is happy with? I have a bazillion files I'd rather not recreate at the moment.

pod2html --recurse in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by KeighleHawk
on Jul 08, 2016 at 14:50

    So I've got to ask, because I really cannot find anyone giving a clear explanation (I suspect weak google-foo and knuckle-headedness on my part). But what exactly does the 'recurse' option for pod2html really do? Because I cannot seem to coerce it into doing anything **I** think it should do. The command does create two tmp files (pod2htmd.tmp and pod2htmi.tmp) that appear as though they would be downright useful for what I want, I just don't seem to get it.

    What I want of course, is for it to recursively search through directories creating *.html files out of anything with perlpod in it. For me, this happens to include *.pod, *.pm and *.pl files. As an added bonus, I have other files with different, or no extensions that have perlpod in them also I would like it to convert.

    It is made easier perhaps in that every directory with files in it with perlpod, ALL of them in that directory have perlpod.

    I've started looking at some of the other ones out there like Pod::Simple::HTMLBatch, but it really bothers me that pod2html has this option that seems like it actually wants to do what I want, but just doesn't do it.

Diagnostic messages in Test::Deep in Seekers of Perl Wisdom
1 direct reply — Read more / Contribute
by KeighleHawk
on Jul 20, 2015 at 19:25
    Related (sorta) to my post in case insensitive deep comparison, I switched a test comparison from Test::More->is_deeply() to Test::Deep->cmp_deeply(). I did this because part of the structure I am comparing includes an array of hashes. Naturally, the array can be returned in random order. Initially, I was using a sort on one of the hash fields, but as my data set increased, I started to hit return values with different hash structures so my sorting column needed to change.

    However, the Test::Deep->bag() method alleviates the need for this by comparing arrays that can be in random order which was far better (I thought) than trying to sort the arrays in the first place. The problem is the messages returned on a failed test. is_deeply would return the exact key/value pair returned and the one expected. cmp_deeply for the same test returned:

    Missing: 1 reference
    Extra: 1 reference

    Not so helpful. Now, I can deal with this by printing out my own messages on fail using Test::More->diag(), but before I go through my code to add all that, I wanted to make sure I was not missing something obvious, especially since Test::Deep touted it's useful diagnostic messages.

    Robert Kuropkat

case insensitive deep comparison in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by KeighleHawk
on Jun 24, 2015 at 21:57
    I'm trying to use Test::More and Test::Deep to compare two complex data structures (nested objects). Ideally, I would use cmp_deeply and pass it both data structures, but do a lower (or upper) case on all the values so the comparison would be case insensitive. Something like
    return cmp_deeply( lc($Expected) , lc($AcTuaL) , "This is my case insensitive comparison" );
    Am I missing something obvious here? I don't want to change the actual data in the structures. I also don't want to just stringify it because I want the diagnostics that come with Test::More to show what values actually fail. Ideas?