This journal is my first foray into a technical annotation of my perl life...
sub days_between($$) {
(str2time($_[1])-str2time($_[0])) / SECONDS_IN_A_DAY;
}
Seems obvious enough. Then some results were non-integer. Boiled down to,
$ perl -MDate::Parse -le 'print ((str2time($ARGV[1])-str2time($ARGV[0]))/86400)' 2004-10-31 2004-11-01
1.04166666666667
$
Why? Ah, Daylight savings!
Dave Gould says:
6 OR 7?
paulm says:
7
Dave Gould says:
scuse caps lock
paulm says:
oh, in that case I don't know
#!/usr/bin/perl
use strict;
use warnings;
# paulm, 2004-10-14
# Provide a pleasant interface to mailman's fix_url.py script
# http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq04.029.htp
my ($program) = $0 =~ m~.*/(.+)$~;
sub usage { die "$program: $program list\@example.com\n@_.\n" }
usage("Missing list address")
unless @ARGV == 1;
my ($local_part, $domain) = split '@', $ARGV[0];
usage ("Couldn't parse $ARGV[0] into a list address")
unless $local_part and $domain;
print "Fixing ${local_part}\@$domain...\n";
system qq{/usr/lib/mailman/bin/withlist -l -r fix_url $local_part -u $domain};
(Lifted from London.pm, this thread on Windows NT v. VMS).
Je 2004-06-11 00:20:29 +0100, Phil Lanch skribis:
> On Wed, Jun 09, 2004 at 02:50:35PM +0100, David Cantrell wrote:
> > I would be *much* happier running the bastard child of VMS
>
> hang on a minute... isn't Windows NT the bastard child of VMS?
$ perl -pe 's/(.)/chr -1+ord $1/ge'
WNT
VMS
$
Apparently.
P
Try "IBM" too
for i in www.paulm.com-access.log.*gz; do
gunzip $i; f=`echo $i | perl -pe 's/.gz//'`;
perl -ni -e 'print unless/^ftp.itransact/' $f;
gzip $f& echo $f;
done
A "zero script" hack (-e0) to convert in-place Macs' default line endings of \r to \n.
perl -le0 -015pi mac_file.txt
The order of the -l and -0 is important. -l assigns $\=$/ (output record sep = input record sep) and then the -015 sets input record separator to octal 15, aka dec 13 aka \r. So it's splitting the input on \r and outputting (via -p) with \n.
(I was puzzled for a while trying to squeeze even more characters out of it by wondering why -l0 was behaving differently to -l -0. -l takes a number too! So the 0 was a number not a command option.)
Can any more chars be shaved off?
I've recently really enjoyed reading the journals on use Perl (in particular Matts's and davorg's I'm sure I'll discover more!) and combined with a feeling I ought to spend time documenting what I get up to with perlif only so I remember in a week's timeit seemed a natural step to join up.
If you know me (heck, even if you don't