Slash Boxes
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 ]

+ -

  Comment: great article (Score 1) on 2010.07.19 10:27

by jmm on 2010.07.19 10:27 (#72182)
Attached to: Happy 10th anniversary, Perl 6
A wonderful article.  At first, I thought that you were unaware of the Topaz incarnation of "Perl 6", but I agree that it is not really something to consider as part of Perl 6 as it became and should not affect the anniversary date.

The mugs jokes had me expecting something that would refer to a broken mug being unable to hold java but could still hold something even more important.

The pugs description brings back great memories of the 2005 YAPC::NA hackathon.  I think it was the second or third hackathon to happen, I was inspired to set it up by the first one Autrijus arranged (in Taiwan?, I think).  A classic geek phenomenon - out of more than a dozen participants, hosted at a summer cottage, no-one went water skiing and there were only a couple of canoe trips taken in the almost a week there, etc.  In fact, I started putting drinks in a cooler out on the deck, partly to have some space in the fridge, but mostly to ensure that some of the people that otherwise wouldn't have done so got outdoors occasionally.
Read More 9 comments
Comments: 9
+ -

  Comment: minor nit (Score 1) on 2010.07.15 14:57

by jmm on 2010.07.15 14:57 (#72165)
Attached to: Phasers are a blast: FIRST and LAST
You don't need a separate boolean to handle LAST - if the loop never ran, then there has never been an assignment of the LAST sub, so: if it is defined call it.
Read More 13 comments
Comments: 13
+ -

  Comment: Re:get another opinion (Score 1) on 2010.07.04 23:20

by jmm on 2010.07.04 23:20 (#72141)
Attached to: Skiing and Gambling and Shooting, in that order
When I last met Chris (aka pudge), he had a wife with him.  (OSCON in 1999)  Now that it is the 21st century (and a decade later) he might have an SO rather than a wife, but I prefer to assume that people have not changed marital status unless I have information to the contrary (and it was only half a decade later when I wrote the reply).
Read More 7 comments
Comments: 7
+ -

  Comment: Re:Babel-17 (Score 1) on 2009.09.14 8:28

by jmm on 2009.09.14 8:28 (#70580)
Attached to: Str and Buf -- I think I get it now
I think it is strongly related to the Sapir-Whorf Hypothesis -
Read More 14 comments
Comments: 14
+ -

  Comment: restricted ability to search (Score 1) on 2009.08.12 9:04

by jmm on 2009.08.12 9:04 (#70012)
Attached to: Use packages?
find srctree -type f | xargs grep Spreadsheet::ParseExcel::Font

The suggested kind of shorthand makes it really hard to do custom searches of your code base, such as for all the code that might happen to use a particular module.  (There might be many modules named mumble::Font - when you separate Spreadshht::ParseExcel unto a separate line from Font you lose the ability to find that unique name using generic tools.
Read More 13 comments
Comments: 13
+ -

  Comment: nothing new here, except the official spec (Score 1) on 2009.08.09 15:19

by jmm on 2009.08.09 15:19 (#69937)
Attached to: "Perl 6 'finished'" isn't the story I want to tell
perl 3 was a language that was useful for production work.

Through the point releases of perl 3 and perl 4 that language got extended drastically - always in a 99.9% backward compatible fashion for each step, and always being useful for production work.

perl 5 was only 99% backward compatible, but turned the language upside down and extended an order of magnitude, and, after the first couple of point releases worked the kinks out, was useful for production work (in an order of magnitude larger number of areas of application).

It's only the last 10 years or so in which there haven't been ongoing constant changes that add totally new major capabilities with amazingly little breakage to existing code - instead there have been smaller, mostly less visible changes in the language with much of the dramatic new capability appearing instead in CPAN and modules (as was the design intent of perl 5).

The only difference with the proposed Rakudo Star and the "traditional" perl release model is that now there is a spec, so the pieces that aren't there yet are known and missed, rather than being happy surprises when the next release comes along. Surely people can be taught to live with that.
Read More 18 comments
Comments: 18
+ -

  Comment: to what language (Score 1) on 2009.07.31 8:06

by jmm on 2009.07.31 8:06 (#69822)
Attached to: Overwrought Security Non Sequitur
Hmm, going to switch from perl, eh?  Perhaps going to a language that does not have a built-in crypt function will give you better security.
Read More 3 comments
Comments: 3
+ -

  Comment: Re:IMHO... (Score 1) on 2009.07.28 8:19

I don't see it as "meaningless-positive-adjective" perl, so much as "memorable-succinct-suggestive-adjective" perl.

A "name" has to serve a lot of purposes.  If it is too long and unmemorable (strict and warnings and Moose Perl) it is not a name but a description.  The name does *not* have to be the description, it just has to be suggestive enough that, once someone learns the description the name will an easy to remember tag that quickly reminds them of the description.  It also is a bug advantage if the name is catchy/interesting enough that someone seeing it for the first time is inspired to investigate and find out what it means (which might mean learning some history to know why the name is suggestive - such as why "modern" perl is different from "traditional" perl).

For example, "Extreme Programming" meant absolutely nothing to me when it was just a name.  After reading about it and the various components, it made an excellent label to identify what I had learned (even though very little in it seems extreme to me - but then I was never too fond of the more traditional methodologies against which it might seem extreme).

Just because you can have marketing speak infested things that have no content does not mean that all marketing speak is bad.  Used with care and in moderation, it can be very powerful and enhance the technical content immensely.
Read More 36 comments
Comments: 36
+ -

  Comment: Re:S02#Whitespace_and_Comments (Score 1) on 2009.07.23 8:49

by jmm on 2009.07.23 8:49 (#69585)
Attached to: Three things in Perl 6 that aren't so great
Hmm, a row of hashes, optionally followed by other text, is often used for a separator, so there is still some potential for getting "special" meaning where none was intended if multi-hash is changed to mean "special" handling.

How about making the special codes a bit harder to get by accident?  Something like #{#  ... #}# - with no whitespace permitted between the braces and the enclosing hashes - for a block delimited comment, perhaps.  That would only be an accidental hazard for people who put a comment in their block header without any whitespace and then try to comment out the line by prepending a hash again without any whitespace.  (My normal practice for commenting out lines is to prepend '# ' - the space after the hash makes it easier to still read the commented out code for when you're decided whether it is time to restore it.  So, I'm not personally liable to get hit by the current spec since I'll comment '{' as '# {' rather than '#{'.)
Read More 16 comments
Comments: 16
+ -

  Comment: Babel-17 (Score 1) on 2009.07.06 12:54

by jmm on 2009.07.06 12:54 (#69322)
Attached to: Str and Buf -- I think I get it now
This "you can't think the wrong thoughts" target reminds me of the novel Babel-17 by Samuel Delaney which uses the same sort of concept but in a human language that causes the person who thinks in that language to automatically think the right thoughts in a very powerful way.
Read More 14 comments
Comments: 14
+ -

  Comment: coming soon (Score 1) on 2009.06.09 13:10

by jmm on 2009.06.09 13:10 (#69020)
Attached to: Apple Cats
... lolcat
Read More 4 comments
Comments: 4
+ -

  Comment: cat herder may be available (Score 1) on 2009.05.21 12:50

by jmm on 2009.05.21 12:50 (#68722)
Attached to: Spending money to help Perl?
As long as the recent proposal for TPF to fund Richard Dice for 6 months is approved, the cat herder post is already covered.  That would make this an auspicious time to provide funds for numerous small projects.  (Of course, I'm just assuming that Richard will want to have his time be volunteered in this fashion - you'd of course have to discuss it with him.)
Read More 16 comments
Comments: 16
+ -

  Comment: encourage repeat courses (Score 1) on 2009.05.19 9:32

by jmm on 2009.05.19 9:32 (#68649)
Attached to: Perl for Geoscience
You should warn your students that followup is necessary to really learn things.

When I first started using vi, I found that it was extremely useful to me.  But, every 6 months to a year, I would read through the entire man page.  Every time, I would find half a dozen "aha" items that provided a command that simplified a process that I would have been doing in a more awkward fashion.  I would then plan to add them to my repertoire.  Usually 2 or 3 would stick, and the others happened just rarely enough that I'd forget about them before an opportunity to use them came along - they would often be an "aha" moment again the next time I read through the man page.  This continued for a couple of decades (and now, with vim adding more features, I'm finding it useful to do this again).

So, make sure your students know that your course (even a full week version, but especially the one day one) will be more than they will fully absorb, that after using the material for a while, some portions will have been used enough that they are very comfortable with them, but other portions will have gotten forgotten or hazy in the meantime.  They should plan to review their course notes regularly - initially every week or so, later every month, etc.  Then, they may find it valuable to take the course again in a year or so, to pick up the subtle items that aren't fully covered in the notes but which come out from the discussion, or the working examples.  The important point, though, is that the learning you get in a course has to be used effectively and integrated into the students ongoing work environment before it will become ingrained; and there is a limit to how much you can retain of the body of knowledge you learn in a course.  While telling students to take the course again sounds somewhat self-serving, assigning them the task of doing the refresher process themselves will give them an opportunity to discover how much they forget and how useful the reviews are.  (Perhaps, you could even have a periodic email suggesting that it is time to review their notes; where these review messages have a gradual backoff in frequency.)
Read More 2 comments
Comments: 2
+ -

  Comment: Re:Money back guarantee (Score 1) on 2009.05.13 9:04

by jmm on 2009.05.13 9:04 (#68565)
Attached to: Software Liability Protection
It would be nice to use that guarantee to get my money back whenever I was forced to accept a copy of Windows along with the hardware that was all I really wanted to get.
Read More 14 comments
Comments: 14
+ -

  Comment: Re:left-to-right recursive generation is very fast (Score 1) on 2009.05.08 9:27

by jmm on 2009.05.08 9:27 (#68494)
Attached to: 'Et tu, bruteforce?'
Your solution does a lot of array copy/filter'ing that mine avoids.  That's not a fault with Perl6, though. :-)

Also, I think yours is still algorithmically slower than mine.  You try every number in every place.  I try every number in the first place, then trying the remaining numbers in the remaining places (not all places).

So, the comparison here is not between Perl5 and Perl6, but coding with always using array ops, and sometimes using individual elements.

I have to go to 9 and 10 to get a user-noticeable elapsed time, but then it starts to take off.  (From the size of the numbers, it is looking like the time is somewhat less than O(n**2), but definitely greater than O(n).

$ time ./ 9

real    0m0.203s
user    0m0.200s
sys    0m0.000s
$ time ./ 10

real    0m1.091s
user    0m1.088s
sys    0m0.000s
$ time ./ 11 | tail -2
17791    10, 8, 5, 2, 9, 6, 2, 7, 5, 11, 8, 10, 6, 4, 9, 7, 3, 1, 4, 1, 3, 11
17792    10, 8, 5, 3, 7, 9, 6, 3, 5, 11, 8, 10, 7, 6, 4, 9, 1, 2, 1, 4, 2, 11

real    0m7.492s
user    0m7.488s
sys    0m0.012s
$ time ./ 12 | tail -2
108143    11, 9, 6, 4, 2, 10, 8, 2, 4, 6, 12, 9, 11, 5, 7, 8, 10, 3, 1, 5, 1, 3, 7, 12
108144    11, 9, 6, 4, 2, 10, 8, 2, 4, 6, 12, 9, 11, 7, 5, 8, 10, 1, 3, 1, 5, 7, 3, 12

real    0m53.187s
user    0m53.155s
sys    0m0.048s
$ time ./ 13 | tail -2

real    6m39.064s
user    6m38.705s
sys    0m0.044s

It's interesting that you can get a hundred thousand solutions for k==12, and none for k==13.

And here's my Perl 5 code:


use strict;
use warnings;

my $n = shift;

($n =~ /^\d+$/) && $n > 2
    or die "Usage: $0 <num>   # num > 2\n";

my @result = ( 0 ) x (2*$n);
my $found = 0;
my $n2 = $n*2;

try( 0, 1..$n );

sub try {
    my( $pos, @nums ) = @_;

    while( $result[$pos] ) {
        return if ++$pos == $n2;

    my $tries = @nums;

    while( $tries-- ) {
        my $guess = shift @nums;
        my $otherpos = $pos+$guess+1;
        return if $otherpos >= $n2;
        unless( $result[$otherpos] ) {
            $result[$pos] = $result[$otherpos] = $guess;
            if( @nums ) {
                try( $pos+1, @nums );
            elsif( $result[0] < $result[-1] ) {
                print ++$found, "\t", join( ', ', @result ), "\n";
            $result[$pos] = $result[$otherpos] = 0;
        push @nums, $guess;
Read More 7 comments
Comments: 7