Shawn H Corey

  • Commented on Why I love Raku
    Do use for-loops for unbounded limits or loops that exit prematurely. Only use them for loops that limits are known and will run to completion....
  • Commented on Bye, bye
    All good things come to an end (hopefully before they become bad things)....
  • Commented on Why I wrote Keyword::DEVELOPMENT
    Got there first 😉
  • Commented on What Time is Midnight?
    The problem is that not every day has 86400 seconds in it. When calculating days between dates, use noon not midnight, as the time of day. If you must know it to the second, convert the date-times to their epochs,...
  • Commented on Dave Cross and Modern PERL
    @Ovid: POSIX is a standard module. It comes installed with Perl. For a list of all the standards modules, see perldoc perlmodlib
  • Commented on Dave Cross and Modern PERL
    Why not use strftime() from POSIX? use POSIX; print strftime( '%Y%m%d%H%M%S', localtime ), "\n"; BTW, SI standard is year, month, day, hour, minute, second....
  • 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;...
  • Commented on What is in The End?
    What's wrong with recursion? A look at recursion....
  • Commented on Is Perl really short of newbies?
    TIMTOWTDI: That's because there is always more than one way to do it, regardless of language. Perl just acknowledges the truth. I've been programming in Perl since version 4. Before that, I used awk, sed, and grep. Back then, Perl...
  • Commented on On Readability
    Saying syntax has no effect on the usability of a language is like saying arithmetic is just as easy with Roman numerals as it is with Arabic numerals....
  • Commented on Change Counting Problem - Feedback Requested
    Put 1¢ to 24¢ in an array: my @small = ( "", "1 penny\n", "2 pennies\n", "3 pennies\n", "4 pennies\n", "1 nickel\n", "1 nickel\n1 penny\n", "1 nickel\n2 pennies\n", "1 nickel\n3 pennies\n", "1 nickel\n4 pennies\n", "1 dime\n", "1 dime\n1 penny\n", "1...
  • Commented on A Tiny Code Quiz
    Try this one: use Data::Dumper; my @a = ( 1 .. 10 ); my $count = () = @a; my @list = () = @a; print Data::Dumper->Dump( [ \@a, $count, \@list ], [qw( *given *count *list )]);...
  • Commented on What if Perl OO was a Core Feature?
    sub new { my $class = shift @_; my $self = { @_ }; return bless $self, $class; } That is not simple?...
  • Commented on What if Perl OO was a Core Feature?
    @Toby Inkster -- my point is that OO should not be used for everything. @Stevan Little -- see above comment about OO fanatics insisting that OO be use for everything. @Olivier Mengué -- You will note how popular Perl 6...
  • Commented on What if Perl OO was a Core Feature?
    Stevan Little -- "Once you start down the dark path, forever will it dominate your destiny." I simply don't believe that once OO is added to Perl, the religious fanatics won't insist OO for everything....
  • Commented on What if Perl OO was a Core Feature?
    If OO becomes part of the core of Perl, I'll learn a new language. The only part of OO that's worth anything is encapsulation and Perl does that with packages. Inheritance is a distraction; Perl already does polymorphism; and code...
  • Commented on I translate "Modern Perl Writing Style" to English
    You should add a section on using Perl::Critic and its script, perlcritic. This will tell you everything about a Perl script or module that is not compatible with PBP. If you use the three argument open, you can use an...
  • Commented on Writing the Perl I Want to See in Others
    Have you tried Perl::Critic and Perl::Tidy?...
  • Posted A Look at Finding Out-of-Date Files to Shawn H Corey

    A function for comparing the modification time of files to determine if a file is out of date with respect to its sources.

    A Look at Finding Out-of-Date Files

  • Posted A Look at Perl to Shawn H Corey

    Two new articles for my blog. The first is on creating a trim() function and its test. The second, is on creating a friendlier interface to Data::Dumper.

    A Place for the Tests

  • Commented on function return in scalar context
    I don't like it because it changes the behaviour of Perl by placing two relevant items far apart. As far as programmers go, out of sight is out of mind. The `use Function::ScalarReturn` has to be place near where the...
  • Posted A Look at Conditional Compiling of Diagnostics to Shawn H Corey

    Is it possible to have conditionally compiled diagnostics in your script and to ensure they don't get printed in production?

    Yes, it is.

  • Posted A Look At My Utility Library to Shawn H Corey

    I am creating a utility module and will be posting about it on my blog.

  • Commented on Encapsulating Responsibility in Methods
    @Ovid: Why should Y be derived from X? That's a big assumption. @Gabor: Big systems that work started as small systems that work. Or, "Whatever happened to FORTRAN III?"...
  • Commented on Encapsulating Responsibility in Methods
    Suppose you have a object A that calls a method in B that calls C that throw an exception X that is caught by A. Now, suppose you change C in B to D, which throws exception Y. You now...
  • Commented on Encapsulating Responsibility in Methods
    Except for exceptions. If you have to change one, you must scan all the code to find were they are caught, to make sure the version will work....
  • Commented on Please provide an abstract for posts to
    I hear you.
  • Posted A Look at Cartesian Products to Shawn H Corey

    A new post in my blog about Cartesian products.

    Problem: You have a number of sets and you want all the combinations when choosing one element from each set.

    In mathematics, these…

  • Posted A Look at Recursion to Shawn H Corey

    I created a blog about Perl over on Blogger and I have just posted an new article on recursion.

  • Commented on C Programming: What is the difference between an array and a pointer?
    Yes, pointers in C will drive you batty. Perl's references are much easier to understand....
Subscribe to feed Recent Actions from Shawn H Corey

  • Klaus Baldermann commented on What Time is Midnight?

    Is that a typo in your last paragraph, or did you really search for 23:53:40 (86000 seconds)?

  • Aristotle commented on Why I wrote Keyword::DEVELOPMENT

    Some dev comes along as says "why are we using the old constant pragma?" So they "fix" the code:

    Might I suggest not hiring people who will dis-improve the code by rote rule-following? 😊

    But also, if that’s your problem:

    use strict; use warnings;
    package DEBUG;
    sub import {
        eval sprintf 'sub %s::DEBUG () { %d } 1', ''.caller, !!$_[1]
            or die

    You can put ample warnings in the POD not to touch that file without talking about it with the dev lead.

    This plays …

  • Ovid commented on Why I wrote Keyword::DEVELOPMENT

    Aristotle, your points are well taken, but I'll point out a subtle affordance that the DEVELOPMENT keyword offers.

    Consider the following:

    else {

    You are correct that this will provide the same opcodes, but it looks wrong and when you can write code where undesired behavior looks wrong, that's awesome. The DEVELOPMENT keyword is designed to augment behavior, not alter it.

  • Tom Wyant commented on Bye, bye

    Just realized -- there are a LOT of copies of META.json on CPAN with things like this in them:

    "meta-spec" : {
    "url" : "",
    "version" : 2

    META.yml does not have this -- guess it's a version 2 thing. Both ExtUtils::MakeMaker and Module::Build do this. I can't speak for other build tools.

  • simonde commented on What are the best Perl one-liners you've written?

    Nothing fancy, but it's handy when you want to pull IP addresses out of log files

    cat /var/log/messages|perl -e 'while (>) {/(\d+\.\d+\.\d+\.\d+)/ && print "$1\n"};'

Subscribe to feed Responses to Comments from Shawn H Corey

About is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.