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 ]

Journal of rafael (2125)

Thursday October 13, 2005
06:58 AM

Perl::Unsafe::Signals

Yesterday I uploaded Perl::Unsafe::Signals to the CPAN. A bit of XS, a bit of a source filter, and you're now theoretically able to turn on unsafe signals behaviour (see PERL_SIGNALS in the perlrun manpage) on a per-block basis. However, it's completely untested yet.
Sunday September 11, 2005
02:10 PM

Flickr

Yay, I got a Flickr account. It's at http://www.flickr.com/photos/rgarciasuarez74/.
Tuesday September 06, 2005
06:01 AM

A subversion tip

I think this can be useful to some.

<@acme> Nicholas: svn diff annoys me too
<@rgs> what's wrong with svn diff ?
<@Nicholas> rgs: http://nick.hates-software.com/
<@rgs> Nicholas: you need to edit diff-cmd in ~/.subversion/config
<@Nicholas> from what to what?
<@rgs> I have this :
<@rgs> ### Set diff-cmd to the absolute path of your 'diff' program.
<@rgs> ### This will override the compile-time default, which is to use
<@rgs> ### Subversion's internal diff implementation.
<@rgs> diff-cmd = /usr/bin/diff
<@rgs> and svn di -x-dpubB works flawlessly :)
<@rgs> ok, it's poorly documented.

Tuesday August 23, 2005
02:49 AM

Shakti, a Perl 6 bot

Hmm, so, I wrote a very simple IRC bot in Perl 6 yesterday evening. It's a karmabot -- it implements the foo++ and bar-- commands that are familiar to purl's friends. Currently found as shakti on #mandrivafr on freenode. (Yes, karma, shakti, all that kind of stuff, we wanted to find a female sanskrit name.)

Here's the code, derived from examples/network/bot_irc.p6 in the pugs sources. Suggestions to make it more perl6ish welcome!

#!/usr/bin/pugs

use v6;

my $nick = "shakti";
my $server = "irc.freenode.net";
my $chan = "#mandrivafr";
my %karma;
my %sux = (
    php => 1,
    python => 1,
);
my %rulz = (
    perl => 1,
    perl6 => 1,
);
my $karmafile = '/tmp/shakti.dump';

sub dump_karma {
    my $fh = open($karmafile, :w) err say "Can't open $karmafile";
    $fh.say("$_:%karma{$_}") for keys %karma;
    $fh.close;
}

# load karma
my $fh = open $karmafile err die "Can't load $karmafile";
for =$fh {
    $_ .= chomp;
    my ($k, $v) = split ":", $_;
    %karma{$k} = $v;
}
$fh.close;

my $hdl = connect($server, 6667);

say "Connected to $server";

$hdl.say("NICK $nick\nUSER $nick $nick $nick $nick");
$hdl.flush;

# discard first line
my $ligne = readline($hdl);

$hdl.say("JOIN $chan");
$hdl.flush;

say "Joined $chan";

while $ligne = =$hdl {

    $ligne .= chomp;

    given $ligne {

        when rx:perl5/^PING/ {
            $hdl.say("PONG $nick");
            $hdl.flush;
        }

        when rx:perl5/^:(.*?)!.*? PRIVMSG $chan (.*)/ {
            my $nick = $0;
            my $msg = $1;
            given $msg {
                when rx:perl5/(\w+)\+\+/ {
                    if $nick eq $0 {
                        $hdl.say("PRIVMSG $chan :$nick: you can't up your own karma!");
                    }
                    else {
                        %karma{lc $0}++;
                        say "increment $0";
                        dump_karma();
                    }
                }
                when rx:perl5/(\w+)--/ {
                    %karma{lc $0}--;
                    say "decrement $0";
                    dump_karma();
                }
                when rx:perl5/\bkarma\s+(\w+)/ {
                    if $0 eq "shakti" {
                        $hdl.say("PRIVMSG $chan :I have infinite karma");
                    }
                    elsif %sux{lc $0} {
                        $hdl.say("PRIVMSG $chan :$0 has very, very bad karma");
                    }
                    elsif %rulz{lc $0} {
                        $hdl.say("PRIVMSG $chan :$0 has infinite karma");
                    }
                    elsif %karma{lc $0} {
                        $hdl.say("PRIVMSG $chan :$0 has karma of " ~ %karma{lc $0});
                    }
                    else {
                        $hdl.say("PRIVMSG $chan :$0 has neutral karma");
                    }
                    $hdl.flush;
                }
            }
        }

    };

}

Thursday August 04, 2005
11:42 AM

Test::LongString 0.08

I just uploaded Test::LongString 0.08 to CPAN, in which a bug was fixed and a new feature implemented [look for $Context in the docs], during the Practical Perl Testing talk. Thanks to whoever asked a question about it during the talk -- the idea comes from him !
Friday May 27, 2005
03:50 AM

Airtight

It occurs to me that Moebius' most excellent comic book Le garage hermétique [from which my workstation's hostname comes] has been canonically translated into English as the Airtight Garage, thus removing the implicit but probably evident reference to Hermes Trismegistus.

I also note the interesting fact that this picture appeared on my defunct blog some years ago, and comes probably from there :)

Tuesday May 17, 2005
10:06 AM

Prefacing

By the way, I forgot to mention that I wrote the preface of this book by Philippe Verdret. Its title, translated to English, would be From Perl to Java: Programming with Regular Expressions. (Wow, 3rd entry. It's journal-day !)
07:48 AM

One-click installation

I wasn't too happy to see that this Linux Distribution Chooser (found via del.icio.us) asserts that Mandriva Linux doesn't support "one-click software installation". I wonder what they mean by that.

Oh, and they also claim that our distribution isn't free. So why can you download ISOs ? And all rpms of free software we produce is available on mirrors, even when not found in the distribution ISOs.

In short, a web site with pretty graphics and all, but they failed to get their facts right.

Friday May 13, 2005
06:57 AM

Sub::Identify

After an idea by Chia-Liang Kao, of svk fame, I uploaded Sub::Identify to CPAN.
Monday April 25, 2005
04:32 AM

Perl 6 cheerleader lines

Inspired by a remark of Larry, and by the fact that some of the Perl 5 annoyances won't be fixed in Perl 5, I came up with a few Perl 6 cheerleader lines.

Fix in six / Fix in six / With much better semantics
Fix in six / Fix in six / That's the best of all gimmicks
Fix in six / Fix in six / And learn a few new cool tricks
Fix in six / Fix in six / And we'll take over Unix
Fix in six / Fix in six / With a few keystrokes and clicks
Fix in six / Fix in six / You will need a new remix
Fix in six / Fix in six / Or maybe in sixty-six
Fix in six / Fix in six / And kill all the heretics
Fix in six / Fix in six / Much more than just aesthetics
Fix in six / Fix in six / Sing all the perl-a-holics
Fix in six / Fix in six / From Larry Wall's alembics
Fix in six / Fix in six / Best of all pharmaceutics
Fix in six / Fix in six / As prove all the statistics
Fix in six / Fix in six / Cures even syphilitics

I'll get my coat.