user-pic

Tom Wyant

  • About: Fine Perl code for over 0.005 centuries.
  • Commented on Converting glob patterns to regular expressions
    Minor tweak: if you are matching file names like File::Glob does, you need to exclude '/' from the characters matched by the wildcards. Unless you are allowing '**' to match truly anything, in which case you need to distinguish it...
  • Commented on Serializers for Perl: when to use what
    Small carp: Storable does not do Regexps, at least out of the box. $ perl -MStorable -E 'store qr{ fubar }smx, fubar.tmp' Can't store REGEXP items at /.../lib/site_perl/5.20.1/darwin-2level/Storable.pm line 259, at -e line 1. $ perl -v; modver Storable This...
  • Posted The Case of the Preferred Parent to Tom Wyant

    In which Dupin expounds on inter-generational relationships.

  • Commented on search.cpan.org
    MetaCPAN has a lot of advantages, but there is one thing about search.cpan.org which I will miss: the fact that development releases were (so to speak) first-class objects. The author's page showed the latest release regardless of whether it was...
  • Posted Stupid <code>less (1)</code> trick to Tom Wyant

    Do you get tired of reading a man page, or even
    POSIX regex engine instead of something more powerful and Perl-like? I
    know I do. Every time I type

  • Commented on The Problem With Perl Testing
    Very thoughtful. And guilty as charged. The thing that puzzles me is how to reorganize. Tests are code. As code, they can have bugs. More than once I have done a small enhancement and had writing and debugging the test...
  • Posted Announcing Perl::Critic::Policy::ControlStructures::ProhibitForeachHandle to Tom Wyant

    A couple days ago I uploaded a Perl-Critic policy to find and complain about things like foreach ( <FOO> ) {...}. The problem (or at least potential problem) with this is that it sucks the entire file into memory before performing the first iteration. Which…

  • Commented on Comment Submission Error
    I hope the Preview button won't be disabled on the original submission page. It's a lifesaver if your submission has markup in it. Disabling either 'Preview' or 'Submit' or both on the preview page may make a great deal of...
  • Commented on A convention for Changes files
    Vim users may find the following useful: :inoremap <F1> <C-R>=strftime("%Y-%m-%d")<CR> If you're in insert or replace mode, this inserts the current date in the proper format at the cursor when the user hits the <F1> key. In normal mode, :nnoremap...
  • Commented on My Love/Hate Relationship with CPAN Testers
    I love CPAN testers unreservedly, and am puzzled by the OP's apparent belief that he, or at least his failing modules, are stigmatized by test failures. I certainly have never felt this way. It almost makes me wonder of the...
  • Commented on Announcing Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter
    Mithaldu: Thanks for the correction. I could have sworn I went looking for warnings::unused and could not find it, but you can't argue with a working URL. "My mind is going, Dave. I can feel it. I can feel it....
  • Posted Announcing Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter to Tom Wyant

    The subject Perl-Critic policy is an alternate implementation of the core policy Variables::ProhibitUnusedVariables. My implementation attempts to do a more thorough job of finding unused variables.

    The…

  • Commented on Don't release experiments to CPAN
    Thank you for the clarification. I have no particular confidence that I could apply your distinction between an experimental module and an experimental implementation to an arbitrary module -- which is not to find fault with you. The fault (if...
  • Commented on Don't release experiments to CPAN
    Why not simply ask people to submit experimental modules under development version numbers? This seems to me (after a grand total of maybe five minutes' thought) to have two advantages over the original proposal: The modules get tested by CPANTESTERS...
  • Commented on Astro::SpaceTrack upgrade
    The Heavens Above web site has a plot of the altitude of the International Space Station over time that you could duplicate. One of my first correspondents was plotting some orbital parameter (ascending node?) of a cluster of Russian navigation...
  • Commented on Astro::SpaceTrack upgrade
    Correction In preparing the threatened release, I discovered that I had pending changes. So: 0.071 will come out today with these changes. 0.072 will come out tomorrow (February 17). It is 0.072 whose only change will be the default value...
  • Posted Astro::SpaceTrack upgrade to Tom Wyant

    For some time now, the Space Track web site, which is the official source for satellite orbital elements, has been working on an upgrade to a REST interface. This interface is scheduled to go live on February 20.

    My module Astro::SpaceTrack retrieves orbital data from the Space Track web s…

  • Commented on A Question of Location
    Wonderful! A piece of deduction worthy of the character in whose mouth you have placed it. I await the next with bated breath....
  • Commented on The Case of the Unexpected Pax
    Have at it. I look forward to your entry. These "cases" were originally going to use a certain late-Victorian London detective, but I was wondering about ownership of the name. But maybe I didn't need to worry. It seems he's...
  • Posted The Case of the Unexpected Pax to Tom Wyant

    It was late afternoon of a chill November in Paris. I was walking along the quai, lost in a brown study. Looking up, I saw my friend C. Auguste Dupin approaching me.

    "Ah, bon soir, mon ami," said Dupin, "and what brings you beside the Seine on this crisp evening?"

    "S…

  • Commented on Writing version of dependencies
    I've been back and forth on this. Currently I specify whatever I use. That is to say if I use Foo; I specify dependency Foo => 0. If I use Foo 1.2; I specify Foo => 1.2. The use of...
  • Commented on RFC Module::Build::CleanInstall
    Module::Build::Cookbook documents command option --uninst 1. It also appears that Module::Build->new( uninst => 1, ... ) has the effect of defaulting the command option to 1, though I can’t find where this is documented. However, I can’t make it actually...
  • Commented on Proc::ProcessTable needs a C lover
    The Linux patch I apply is https://rt.cpan.org/Public/Bug/Display.html?id=41397 -- there are others, but I seem to get along without them. Under OpenBSD, I apply https://rt.cpan.org/Public/Bug/Display.html?id=77094 Perhaps more interestingly, a respondent to that ticket expressed the intent to refactor the module. And...
  • Commented on How many ways can I use thee, module?
    use Module::Load; load MODULE; use if CONDITION, MODULE => ARGUMENTS...
  • Commented on Finding Unused Subroutines, but with PPI
    There's always perlcritic --single UnusedPrivateSubroutines, if its assumptions are what you want. If not, this policy might be a good starting point to roll your own. The policy uses a Perl::Critic::Document rather than a PPI::Document, but the former is easily...
  • Commented on The Case of the Incompatible Safe -- Epilog
    Well, then thanks to Paul Johnson and thanks to Rafaël for pointing out where the credit was due. Who gets credit for what is not always obvious to outsiders -- or at least, not to me. I noticed a note...
  • Posted The Case of the Incompatible Safe -- Epilog to Tom Wyant

    "You know," I said to my friend C. Auguste Dupin, "I can not help feeling that there must be a simpler solution for M. Tueur's problem of the Incompatible Safe".

    "But there is, mon ami…

  • Commented on On defined(@array) and defined(%hash)
    If the test suite does anything at all, it will let both authors and users know when there is a problem. This is, by the way, an argument for running tests. When I find such problems I file a bug...
  • Posted Stupid <code>ack</code> trick to Tom Wyant

    My source directories tend to collect cruft, and it can be a pain to separate the real ack hits from the crufty ones. I am ashamed to say how long it took me to think of the following:

    function ackx {

  • Commented on More module versioning pain
    My first thought is that there ought to be a test for this. My second thought was that if the version module was involved, they are actually the same version number, appearances to the contrary notwithstanding. And sure enough, Mail::SPF...
Subscribe to feed Recent Actions from Tom Wyant

  • brian d foy commented on Converting glob patterns to regular expressions

    A * might be inside [...], which would be like Perl's character classes. In that case, you want to leave it alone. :)

  • Aristotle commented on Converting glob patterns to regular expressions

    But I like the spread-out version better. :-) I find it much easier to understand what’s going on there.

    And I typically find it easier to reason about stars and pluses than counted repetitions, even if it means I have to count dots.

    So I think I would have written this like so:

    1 while s/[*]+([?]+)[*]*/$1*/g;
     
    s[
        ([?][*]+)
        |([?])
        |([*]+)
        |(\W)
    ]{
        ; $1 ? '.+'
        : $2 ? '.'
        : $3 ? '.*'
        : quotemeta $4
    }xge;

    That is, first, shuffle around question marks while collapsing wildcards as soon as pos…

  • shawnhcorey commented on Converting glob patterns to regular expressions

    Or you could use a hash for the convertion:

    my %convert = (
    '*' => '.*',
    '?' => '.',
    );

    s/(\W)/$convert{$1}||$1/eg;

  • Neil Bowers commented on Converting glob patterns to regular expressions

    You could have a look at glob_to_regex() in Text::Glob.

    I haven't checked it, but if it doesn't handle the cases discussed here, you could submit a PR tomorrow, as part of your CPAN Day celebration :-)

    And while you're there, you could add the github repo to the dist's metadata, so it will appear in the sidebar on MetaCPAN.

  • smls commented on Converting glob patterns to regular expressions

    I wrote this once, for one of my own scripts:

    
    # Given a glob pattern, return a regex that has the following behavior when
    # matched against Cwd::realpath canolicalized path strings:
    #  - matches successfully if and only if the path would have been matched by
    #    the original glob
    #  - $1, $2, ... will contain what would have been matched by groups of
    #    consecutive wildcards (*, ?, [...]) in the original glob
    #  - $::REGMARK will contain the numeric index of the "brace expansion"
    #    alternative in the original glob that would have first matched the path
    # If  tree => 1 …
Subscribe to feed Responses to Comments from Tom Wyant

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.