The uploaded file
DateTime-Format-Builder-0.76.tar.gz
has entered CPAN as
file: $CPAN/authors/id/S/SP/SPOON/DateTime-Format-Builder-0.76.tar.gz
size: 81462 bytes
md5: b33b496586a517a405b59e6628dbecac
Changes for 0.76 (10 Aug 2003)
- Fallthrough example and test added.
- Quick parser added to simplify fallthrough stuff.
- Rejigged internals to allow for on_fail argument to
multi-parsers.
This is my most complex module. Every time I change it I fear for my sanity. Thankfully these latest changes will lead to me being able to simplify a lot of the code.
(original at my bliki [ghastly term])
perlreref is a quick regex reference that brings together the gist of the disparate regex docs, thus giving people a single place to look if they just want to check something quickly.
I've thrown it around on irc and on the perl documentation list and taken suggestions. I gave it to p5p, and it's now in bleadperl.
There's a search.cpan.org-alike HTML version and the raw pod.
Some search.cpan.org tricks:
Given a dist: DateTime::Format::HTTP
These are all the same page:
And to go straight to the module's docs:
Fun. Wonder if there are any others.
djberg96 mentioned today:
sigh...why do they do soundex matching on cpan? it's pointless
Which makes me think: If the source were available someone could write gbarr a new search, could demonstrate its use and then, hopefully, persuade gbarr to use it.
Well, now I'm at Advogato too. Guess I can also not maintain a regular journal there too =)
BTW: follow that link and certify me, please. I'd like to be able to at least reply to articles =)
It's surprising how easily and quickly Java code can be turned into Ruby code.
class Array
def bsearch ( target )
high = self.length
low = -1
while high - low > 1
probe = (high + low) / 2
if self[probe] > target
high = probe
else
low = probe
end
end
if low == -1 || self[low] != target
return -1
else
return low
end
end
def bsearch_dups ( target )
high = self.length
low = -1
while high - low > 1
probe = (high + low) / 2
if self[probe] < target
low = probe
else
high = probe
end
end
if high == self.length || self[high] != target
return -1
else
return high
end
end
def range ( floor, ceiling )
answer = []
# work on floor
high = self.length
low = -1
while high - low > 1
probe = (high + low) / 2
if self[probe] < floor
low = probe
else
high = probe
end
end
answer[0] = low
# work on ceiling
high = self.length
low = -1
while high - low > 1
probe = (high + low) / 2
if self[probe] > ceiling
high = probe
else
low = probe
end
end
answer[1] = high
return answer
end
end
No doubt it could be written more clearly, but even with the basic translation it's nicer than the Java version. For a start, the routines are now methods on Arrays. Damn sensible place to keep them, although I'm sure several of the 4 readers of this post will disagree (including myself depending on the phase of the moon).
Secondly, it's type free.[1] This is a good thing.
Thirdly, think about this code in Perl. What would be written differently? Would you be tempted to have another parameter, a comparator? What would you do about the difference between comparing strings and numbers?
Enough of this for now.
[1] I'm sure there's a better, or more correct, term ('independent', 'agnostic', something), but I don't know it. Feel free to comment it.
No, it doesn't handle every file extension. Nor every package. Nor does it take parameters. Yes, you have to modify the source to make it do anything useful for you . No, I'm not particularly concerned. Just thought someone might be amused by it =)
For something more useful: DateTime::Format::Excel (docs).
#!/usr/bin/perl -w
use strict;
use YAML;
use PerlIO::gzip;
my $packages = do {
my %packages;
open my $pkgs_fh, '<:gzip',
'minicpan/modules/02packages.details.txt.gz'
or die "Cannot open pkgs: $!\n";
while (<$pkgs_fh>)
{
$packages{$2} = $1 if m[ ^ \S+ \s+ \S+ \s+
[A-Z]/[A-Z][A-Z]/([A-Z]+)/(\S+)(?:\.(?:tar\.gz|zip))
$ ]x;
}
close $pkgs_fh;
\%packages;
};
print "Read the details of ".(keys %$packages)." packages.\n";
my %authors;
while (<DATA>)
{
chomp;
printf "%30.30s => %s\n", $_, $packages->{$_};
push @{ $authors{ $packages->{$_} } } , $_;
}
print Dump(\%authors);
__DATA__
Acme-Hello-0.02
Apache-Filter-1.022
B-Generate-1.06
Class-Container-0.10
Crypt-SKey-0.06
HTML-SimpleParse-0.11
Module-Build- 0.16
Test-Signature-1.03
Text-WikiFormat-0.6
Thesaurus-0.21
WWW-SherlockSear ch-0.14
WWW-Shorten-1.5.6
WWW-Yahoo-Groups-1.7.7
XML-RSS-Aggregate-0.02
opti mize-0.03
types-0.05
I'm a slacker. I really am. I've been working on the books.perl.org site for a number of months now. I'm closer to getting it to where I like it, but have some problems.
Number 1 is: page design. It's great, except for the actual book page. I've had one suggestion for an alternate design. [1] But that only affects the outside material, not the actual page content.
Suggestions welcome.
Also, there's the data front. Need lots of data in the system. We have basic details of 95 books. 8 of those also have blurbs and such. Most are categorised somehow. And I've got a mozilla bookmark folder containing another 20-30 books to be added; mental notes of another dozen.
Shame XML::Simple broke. There goes my nice 'grab details from Amazon.com when adding a book' feature.
Covers are another fun thing. Currently, we've misappropriated most of them. We have permission from a number of publishers to put up whatever we like, which is nice. However that still entails getting nice images. Mostly using Amazon.com images currently, and they're somewhat crap.
[1] Yes, the tabs don't actually work yet. Mockup rather than proof of concept.
All will become clear, later.
#!/usr/bin/perl -w
use strict;
use WWW::UsePerl::Journal;
my $subject = <>;
chomp $subject;
my $entry = join( '', <> );
my $j = WWW::UsePerl::Journal->new('fred');
$j->login('xxxx');
$j->postentry(
title => $subject,
text => $entry,
);
[updated with petdance's changed]