My adventures using Perl. I use it for Oddmuse and whenever I need to get things done quickly.
I maintain a wiki engine called Oddmuse. It’s the software used to run my blog, for example. It is written in an older scripting language called Perl. Perl predates Unicode. That’s why the use of UTF-8 or UTF-16 is not mandated. That, in turn, means that usually bytes are interpreted as an UTF-8 encoded character is only visible as two bytes.
Consider this regular expression to match WikiWords: [A-Z][a-z]+[A-Z][a-z]+
How would you extend it to parse ÖlPlattform?
Assume the following Perl code was written in a source file that was UTF-8 encoded:
$str = "OelPlattform"; print "OelPlattform YES\n" if $str =~ /[[:upper:]][[:lower:]]+[[:upper:]]\w+/; $str = "ÖlPlattform"; print "ÖlPlattform YES\n" if $str =~ /[[:upper:]][[:lower:]]+[[:upper:]]\w+/;
This will just print OelPlattform YES because what looks like “ÖlPlattform” actually starts with the bytes C3 96 and C3 is not an upper case letter. It’s actually unclear what it is. In a Latin-1 environment the C3 would print as ×the dreaded sign of encoding errors!
I wanted to keep Oddmuse encoding agnostic. Users could specify a different encoding which would be served together with the page HTML such that they could have wikis using GB 2312. This is why Oddmuse contained the following line and similar code:
# we treat input and output as bytes
eval { local $SIG{__DIE__}; binmode(STDOUT, ":raw"); };This resulted in problems when some packages I was using did in fact produce UTF-8 and so I had to use code as follows:
eval { local $SIG{__DIE__}; binmode(STDOUT, ":utf8"); } if $HttpCharset eq 'UTF-8';
print RSS($3 ? $3 : 15, split(/\s+/, UnquoteHtml($4)));
eval { local $SIG{__DIE__}; binmode(STDOUT, ":raw"); };I’m not sure why I surrounded it all with an eval—I assume it was to support an older version of Perl but I’m not sure.
Ok, so I wanted to get rid of all that.
The solution seems deceptively simple: add use utf8; to the source files and open all files using the UTF-8 encoding layer.
When printing UTF-8 to STDOUT, you need to tell Perl that STDOUT can in fact handle multi-byte characters. Since the HTML produced is UTF-8 encoded, I know that this is true. If you don’t, you’ll get “wide character in print” warnings.
binmode(STDOUT, ':utf8');
You need to be careful with all input and output, however.
open(F, '<:encoding(UTF-8)', $RcFile);
The same is true for output:
open(OUT, '>:encoding(UTF-8)', $file)
or ReportError(Ts('Cannot write %s', $file) . ": $!", '500 INTERNAL SERVER ERROR');Oddmuse also offers the ability to include other pages (Transclusion) and to produce feeds. This can be a problem. The default page processing is to parse the raw text and start printing HTML as soon as possible because I have always felt that it was more expedient to start printing the top of the page while the rest was still being parsed. What happens when I don’t want to do this, eg. I’m in the middle of building the RSS feed?
The solution I had been using was to redirect STDOUT to a variable. Perl calls this a “memory file.” The problem is the encoding of this memory file:
Here’s what I had to write:
open(STDOUT, '>', \$page) or die "Can't open memory file: $!"; binmode(STDOUT, ":utf8"); PrintPageHtml(); utf8::decode($page);
I think this works because binmode tells all the print instructions that it’s ok to print multi-byte characters and utf8::decode makes sure that all those bytes are in fact decoded back to Perl’s internal representation.
Then I discovered that I needed to look at the bytes if I wanted to URL-encode strings:
utf8::encode($str); # turn to byte string
my @letters = split(//, $str);
my %safe = map {$_ => 1} ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.', '!', '~', '*', "'", '(', ')', '#');
foreach my $letter (@letters) {
$letter = sprintf("%%%02x", ord($letter)) unless $safe{$letter};
}Now that I’m looking at the above I wonder what sort of bugs I’m introducing with the inverse operation that I haven’t changed:
$str =~ s/%([0-9a-f][0-9a-f])/chr(hex($1))/ge;
I feel that this requires a call to utf8::decode when done! Strangely enough none of my tests have picked this up. 
(Actually I think I know why I haven’t stumbled across this problem: I only use the function to decode the Cookie, and all the functions accessing the cookie go through an extra encoding/decoding step that would not be necessary if I had fixed the URL-decoding function.
)
Another problem I stumbled upon: directories. Directories often ended up Latin-1 encoded.
utf8::encode($newdir);
return if -d $newdir;
mkdir($newdir, 0775)
or ReportError(Ts('Cannot create %s', $newdir) . ": $!", '500 INTERNAL SERVER ERROR');The reason I didn’t discover I had the same problem with filenames was that I’m using a compatibility layer on my Mac when I do my developments. The Mac uses UTF-8 NFD instead of UTF-8 NFC as is the standard on the web. Thus if you take bytes encoding a filename from the web and create the file, or if you go the other way, you have a problem. I store the index of all pages in a files. When a new page is created, I get the page name (NCF encoded) from the web, and store it in a file. When I read the file, the content contains the NFC bytes and with these, I cannot find the NFD encoded file (because the filesystem changed the encoding as it wrote the file). I hated it so much. Thus, the Mac compatibility layer does an extra encoding and decoding to get everything from NFD to NFC—and thereby protected me from this error.
As soon as I installed it on my sites, however—they all use Debian and ext3 filesystems, I think—I had a problem.
The necessary fix:
utf8::encode($file);
if (open(IN, '<:encoding(UTF-8)', $file)) {
local $/ = undef; # Read complete files
my $data=<IN>;
close IN;
return (1, $data);
}And:
utf8::encode($file);
open(OUT, '>:encoding(UTF-8)', $file)
or ReportError(Ts('Cannot write %s', $file) . ": $!", '500 INTERNAL SERVER ERROR');
print OUT $string;
close(OUT);Another stumbling block was that the non-breaking space was no longer just a byte sequence like any other, namely C2 A0. Perl suddenly recognized it as whitespace! This is a problem if a path contains non-breaking spaces! The old code translated spaces to underscore characters, so that wasn’t really a possibility. But whenever I had been “smart” and used a non-breaking space, I now had a problem. The glob function splits its arguments on whitespace. Where there was one pattern, I now had two broken patterns!
Here’s an example:
glob(GetKeepDir(shift) . '/*.kp'); # files such as 1.kp, 2.kp, etc.
Here’s another example:
foreach (glob("$PageDir/*/*.pg $PageDir/*/.*.pg"))The solution is to use File::Glob ':glob' and replace every occurence of glob with bsd_glob. Wow, my application was very much unsuited to filenames containing whitespace and I hadn’t even realized it!
foreach (bsd_glob("$PageDir/*/*.pg"), bsd_glob("$PageDir/*/.*.pg"))Remember the regular expression to detect wiki words I used at the top? This was the actual regular expression I had been using:
$WikiWord = '[A-Z]+[a-z\x80-\xff]+[A-Z][A-Za-z\x80-\xff]*';
Essentially wiki words only worked for a first letter containing an ASCII upper case letter.
At first, I switched this to the following regular expression (trying to minimize changes):
$WikiWord = '[A-Z]+[a-z\x{0080}-\x{ffff}]+[A-Z][A-Za-z\x{0080}-\x{ffff}]*';It turns out that Perl 5.8 chokes on this regular expression, howeveer. FFFE and FFFF are noncharacters. I had to change the regular expression.
$WikiWord = '[A-Z]+[a-z\x{0080}-\x{fffd}]+[A-Z][A-Za-z\x{0080}-\x{fffd}]*'; # exclude noncharacters FFFE and FFFFI’m sure this list isn’t complete but I’m sure it’s long enough to illustrate my main point: this is painful. It’s HTML quoting all over again.

I’ve been working on a submission form for the Old School RPG Planet. Today I added another little feature. This is how I like to develop code. No time pressure. One little step at a time. Keep polishing it.
The planet uses Planet Venus to collect the RSS and Atom feeds of many of the Old School RPG blogs out there. Planet Venus allows you to get the list of feeds via an URL. I’m hosting the list of feeds on Campaign Wiki itself (raw format). As you can see, it the format doesn’t look nice.
The thing I did, therefore, was to write a script that makes it easy for people who are not into the technical details to submit new blogs. It also makes it easier for me to submit new blogs!
The things it handles:
http:// and try again.application/rss+xml, application/atom+xml, application/xml (yeah) and text/xml (just making sure) and allow the user to pick one of them.I think it’s pretty cool.
If you look at the interface, you’ll note that it has a link to its own source code. I love this little Perl trick:
__DATA__ at the end of the source file. Usually you would add actual data at the end. The script could read it using the DATA file handle.seek DATA, 0, 0; print "Content-type: text/plain; charset=UTF-8\r\n\r\n", <DATA>; This resets the current position of the DATA file handle to the beginning of the source file. Tadaa! 
I’m currently working on randomly generating islands using the ideas presented in Polygonal Map Generation by Amit. Check out his Flash demo! I am nowhere as far, yet. I’m writing my code in Perl and producing SVG output.
See below for source code used. I’d install it on a public server, but unfortunately there are quite some dependencies…
#! /usr/bin/perl -w
# Copyright (C) 2011 Alex Schroeder <alex@gnu.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use CGI qw(:standard);
use SVG;
use Math::Geometry::Voronoi;
use Class::Struct;
use Math::Fractal::Noisemaker;
use List::Util qw(min max);
use Data::Dumper;
my $points = 3000;
my $width = 1000;
my $height = 550;
my $center_x = $width / 2;
my $center_y = $height / 2;
my $radius = 500;
my %color = (beach => '#a09077',
ocean => '#44447a',);
struct World => { points => '@',
centroids => '@',
voronoi => '$',
height => '@',
};
sub add_random_points {
my ($world) = @_;
for (my $i = 0; $i < $points; $i++) {
push(@{$world->points}, [rand($width), rand($height)]);
};
# print(join("\n", map {join(",", $_->[0], $_->[1])} @{$world->points}));
return $world;
}
sub add_voronoi {
my ($world) = @_;
$world->voronoi(Math::Geometry::Voronoi->new(points => $world->points));
$world->voronoi->compute;
}
sub add_centroids {
my ($world) = @_;
$world->centroids([]); # clear
foreach my $polygon ($world->voronoi->polygons) {
push(@{$world->centroids}, centroid($polygon));
}
}
sub centroid {
my ($cx, $cy) = (0, 0);
my $A = 0;
my $polygon = shift;
my ($point_index, @points) = @$polygon; # see Math::Geometry::Voronoi
my $point = $points[$#points];
my ($x0, $y0) = ($point->[0], $point->[1]);
for $point (@points) {
my ($x1, $y1) = ($point->[0], $point->[1]);
$cx += ($x0 + $x1) * ($x0 * $y1 - $x1 * $y0);
$cy += ($y0 + $y1) * ($x0 * $y1 - $x1 * $y0);
$A += ($x0 * $y1 - $x1 * $y0);
($x0, $y0) = ($x1, $y1);
}
$A /= 2;
$cx /= 6 * $A;
$cy /= 6 * $A;
return [$cx, $cy, $point_index];
}
sub add_height {
my $world = shift;
$Math::Fractal::Noisemaker::QUIET = 1;
my $grid = Math::Fractal::Noisemaker::square();
$world->height([]); # clear
my $scale = max($height, $width); # grid is a square
foreach my $point (@{$world->points}) {
my $x = int($point->[0]*255/$scale);
my $y = int($point->[1]*255/$scale);
my $h = 0; # we must not skip any points!
$h = $grid->[$x]->get($y) / 255
unless $x < 0 or $y < 0 or $x > 255 or $y > 255;
push(@{$world->height}, $h);
}
}
sub raise_point {
my ($world, $x, $y, $radius) = @_;
my $i = 0;
foreach my $point (@{$world->points}) {
my $dx = $point->[0] - $x;
my $dy = $point->[1] - $y;
my $d = sqrt($dx * $dx + $dy * $dy);
my $v = max(0, $world->height->[$i] - $d / $radius);
$world->height($i, $v);
$i++;
}
}
sub svg {
my $world = shift;
my $svg = new SVG(-width => $width,
-height => $height, );
foreach my $polygon ($world->voronoi->polygons) {
my ($point_index, @points) = @$polygon; # see Math::Geometry::Voronoi
my $x = $world->points->[$point_index]->[0];
my $y = $world->points->[$point_index]->[1];
next if $x < 0 or $y < 0 or $x > $width or $y > $height;
my $z = int($world->height->[$point_index] * 255);
my $color = $z == 0 ? $color{ocean} : "rgb($z,$z,$z)";
my $path = join(",", map { map { int } @$_ } @points);
$svg->polygon(points => $path,
fill => $color,
style => { 'stroke-width' => 1,
'stroke' => 'black'});
}
return $svg->xmlify();
}
sub response {
print header(-type=>'image/svg+xml');
print shift;
}
sub main {
if (path_info eq '/source') {
seek DATA, 0, 0;
print "Content-type: text/plain; charset=UTF-8\r\n\r\n", <DATA>;
} else {
srand(param('seed') || time);
my $world = new World;
add_random_points($world, $points);
add_voronoi($world);
for (my $i = 2; $i--; ) {
# Lloyd Relaxation
add_centroids($world);
$world->points($world->centroids);
add_voronoi($world);
}
# skip corner improvement
# skip Delaunay triangulation
add_height($world);
raise_point($world, $center_x, $center_y, $radius);
# draw
response(svg($world));
}
}
main ();
__DATA__I maintain the Old School RPG Planet. The list of feeds it manages is saved on a wiki page. I wanted to write a little script that will allow me to quickly add feeds to that list. And I did! There’s now a way to submit new feeds to the feed instead of editing the wiki page.
The problem? The thing tries to parse web pages, trying to discover feed addresses. And that works well for sites that validate. But the two first Blogspot sites I tried each had over two hundred errors! Once the markup is borked, parsing doesn’t work, and thus feed discovery doesn’t work.
Now, if I need to work around broken markup, I start wondering why tried to standardize HTML… What a glorious waste of time! In the end, we just treat it as tag soup anyway. 
If you’re still interested in the source code, no problem. Lately all my CGI-scripts are able to spew forth their source code.
Unfortunately it is not complete, yet. It doesn’t update the wiki page. I didn’t bother once I realized that the entire parsing idea was not going to work. 
Update: Wohoo, replaced HTML and XML parsing with regular expression matching, wrote what I needed, and finished the script! [1] 
Comments on 2010-10-15 Web Standards Dream Bubble
Throwing errors at human-generated content is kind of a silly approach, especially when the human who created it is long gone and unable to correct the errors. It seems much easier to just assume that every input must mean something, even if you are risking that it’s not quite the same thing that the author had in mind. To be honest I am really surprised that Perl, which follows this philosophy itself somewhat, doesn’t have a forgiving HTML parser that you could use.
– RadomirDopieralski 2010-10-16 19:00 UTC
– AlexSchroeder 2010-10-16 19:28 UTC

– AlexSchroeder 2010-10-16 22:59 UTC
The awesome answer on Stack Exchange notwithstanding:
– AlexSchroeder 2010-10-19 11:01 UTC
At home I have Net::SMTP::TLS and Net::SMTP::SSL installed and I’ve managed to use both to send mail via my Google account.
On one of my hosting services, I have only Net::SMTP::SSL, and it just won’t work.
Debug output at home:
Net::SMTP::SSL>>> Net::SMTP::SSL(1.01) Net::SMTP::SSL>>> IO::Socket::SSL(1.24) Net::SMTP::SSL>>> IO::Socket::INET(1.31) Net::SMTP::SSL>>> IO::Socket(1.31) Net::SMTP::SSL>>> IO::Handle(1.28) Net::SMTP::SSL>>> Exporter(5.58) Net::SMTP::SSL>>> Net::Cmd(2.29) Net::SMTP::SSL=GLOB(0x186fc04)<<< 220 mx.google.com ESMTP 24sm915314eyx.9 Net::SMTP::SSL=GLOB(0x186fc04)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x186fc04)<<< 250-mx.google.com at your service, [80.219.173.68] Net::SMTP::SSL=GLOB(0x186fc04)<<< 250-SIZE 35651584 Net::SMTP::SSL=GLOB(0x186fc04)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x186fc04)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x186fc04)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x186fc04)<<< 250 PIPELINING Net::SMTP::SSL=GLOB(0x186fc04)>>> AUTH LOGIN Net::SMTP::SSL=GLOB(0x186fc04)<<< 334 VXNlcm5hbWU6 Net::SMTP::SSL=GLOB(0x186fc04)>>> a2Vuc2FuYXRh Net::SMTP::SSL=GLOB(0x186fc04)<<< 334 UGFzc3dvcmQ6 Net::SMTP::SSL=GLOB(0x186fc04)>>> VGgsYmFpZA== Net::SMTP::SSL=GLOB(0x186fc04)<<< 235 2.7.0 Accepted Net::SMTP::SSL=GLOB(0x186fc04)>>> MAIL FROM:<kensanata@gmail.com>
Notice the AUTH LOGIN command.
Debug output on my host:
Net::SMTP::SSL>>> Net::SMTP::SSL(1.01) Net::SMTP::SSL>>> IO::Socket::SSL(1.16) Net::SMTP::SSL>>> IO::Socket::INET(1.31) Net::SMTP::SSL>>> IO::Socket(1.30_01) Net::SMTP::SSL>>> IO::Handle(1.27) Net::SMTP::SSL>>> Exporter(5.62) Net::SMTP::SSL>>> Net::Cmd(2.29) Net::SMTP::SSL=GLOB(0xa025520)<<< 220 mx.google.com ESMTP 10sm135225eyz.42 Net::SMTP::SSL=GLOB(0xa025520)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0xa025520)<<< 250-mx.google.com at your service, [83.137.100.36] Net::SMTP::SSL=GLOB(0xa025520)<<< 250-SIZE 35651584 Net::SMTP::SSL=GLOB(0xa025520)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0xa025520)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0xa025520)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0xa025520)<<< 250 PIPELINING Net::SMTP::SSL=GLOB(0xa025520)>>> MAIL FROM:<kensanata@gmail.com> Net::SMTP::SSL=GLOB(0xa025520)<<< 530-5.5.1 Authentication Required. Learn more at Net::SMTP::SSL=GLOB(0xa025520)<<< 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 10sm135225eyz.42
Notice the error: Authentication Required.
Why is the same script (I checked twice – I sure hope I’m not confusing anything) not using the AUTH LOGIN command?
I don’t understand.
my $mail = new MIME::Entity->build(To => $from, # test! From => $from, Subject => 'Test Net::SMTP::SSL', Path => $fh, Type => "text/html"); my $smtp = Net::SMTP::SSL->new($host, Port => 465, Debug => 1); $smtp->auth($user, $password); $smtp->mail($from); $smtp->to($from); # test! $smtp->data; $smtp->datasend($mail->stringify); $smtp->dataend; $smtp->quit;
Source is available. [1]
Output of perl -MNet::SMTP::SSL -wle 'for (keys %INC) { next
if m[^/]; $m = $_; $m =~ s[/][::]g; $m =~ s/\.pm$//; print "$m ",
$m->VERSION || "<unknown>" }' as suggested on #perl:
| At home | Remote system |
|---|---|
Net::SSLeay 1.35 IO::Handle 1.28 List::Util 1.14 SelectSaver 1.00 IO::Socket 1.31 warnings 1.03 Symbol 1.05 Scalar::Util 1.14 IO::Socket::INET 1.31 Exporter 5.58 Errno 1.09 IO::Socket::SSL 1.24 warnings::register 1.00 XSLoader 0.02 Net::Config 1.11 Net::Cmd 2.29 utf8 1.04 Config <unknown> IO 1.25 IO::Socket::UNIX 1.23 Carp 1.03 bytes 1.01 Exporter::Heavy 5.58 Net::SMTP 2.31 vars 1.01 strict 1.03 Net::SMTP::SSL 1.01 constant 1.04 Socket 1.77 AutoLoader 5.60 DynaLoader 1.05 | Net::SSLeay 1.35 XSLoader 0.08 IO::Handle 1.27 warnings::register 1.01 Net::Config 1.11 List::Util 1.19 SelectSaver 1.01 Net::Cmd 2.29 IO::Socket 1.30_01 warnings 1.06 utf8 1.07 IO::Socket::UNIX 1.23 IO 1.23_01 Symbol 1.06 bytes 1.03 Carp 1.08 Net::SMTP 2.31 Scalar::Util 1.19 Exporter::Heavy 5.62 IO::Socket::INET 1.31 Net::SMTP::SSL 1.01 strict 1.04 vars 1.01 Exporter 5.62 constant 1.13 Socket 1.80 Errno 1.1 IO::Socket::SSL 1.16 AutoLoader 5.63 |
Hm…
Update: I found the problem and submitted a bug: The remote system is a Debian system, and the admin installed libnet-smtp-ssl-perl. If you look at the Net::SMTP code, however, you’ll see the following:
sub auth {
my ($self, $username, $password) = @_;
eval {
require MIME::Base64;
require Authen::SASL;
} or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL
todo auth"]), return 0;There is therefore a dependency on Authen::SASL. If you don’t have that module, sending your email will fail in a non-obvious way, as seen above. Installing libauthen-sasl-perl fixes the problem.
Comments on 2009-10-02 I hate the Perl SMTP libraries
Thanks for the heads up on the Authen::SASL dependency…been working on it for hours and getting nowhere.
– Fred 2009-12-09 18:34 UTC
I’m not sure what to make of the response given to the bug report. Does Gregor agree with me or not? It’s weird. 
– AlexSchroeder 2009-12-09 23:24 UTC
Based on Harold Bakker's APOD script, I offer the following solution. I don’t keep my computer running, so I just install the following Apple Script as a login item (→ System Preferences → Accounts → Login Items):
(* Place your with timeout statement within a try... on error statement to prevent the script from stopping when a timeout occurs. *) try -- Give the script a three minute timeout to prevent problems when this is run as a login item with timeout of 180 seconds do shell script "~/bin/apod.pl >> /var/tmp/console.log" -- append the result to the console log end timeout on error errMsg -- display a dialog only if an error occurs display dialog errMsg giving up after 10 end try
You should probably create a new script using the Script Editor on your system, paste the above, and save it as an application. Remember to untick the startup screen checkbox.
You’ll notice that it runs a Perl script called /bin/apod.pl – you should create that directory, put the following Perl script in it, and make it executable. I keep both apod.app and apod.pl in the same /bin directory.
#!/usr/bin/perl
# This script will download the astronomy picture of the day and set
# it as the current desktop background.
# originally by Harold Bakker, harold@haroldbakker.com
# http://www.haroldbakker.com/
# changes by Alex Schroeder <alex@gnu.org>
# http://emacswiki.org/alex/
use strict;
use LWP::UserAgent;
use File::Temp qw/tempfile/;
my $ua = LWP::UserAgent->new;
my $response = $ua->get("http://antwrp.gsfc.nasa.gov/apod/astropix.html");
if ($response->is_success
and $response->content =~ /href\="image\/([^\/]+)\/(.*?)"/) {
my $url = "http://antwrp.gsfc.nasa.gov/apod/image/$1/$2";
my $filename = $2;
$response = $ua->get($url);
if ($response->is_success) {
my ($fh, $tempfile) = tempfile(UNLINK=>0);
print $fh $response->content;
close $fh;
open(F, "|/usr/bin/osascript") or die "Cannot run Apple Script: $!";
print F <<END;
tell application "Finder"
set pFile to POSIX file "$tempfile" as string
set desktop picture to file pFile
end tell
END
} else {
die $response->status_line;
}
} else {
die $response->status_line;
}This should work fine as long you restart your computer about once a day. I haven’t made sure that it will try to reuse images, saving the last one in a save place, etc.
Once I had the name generator, I was ready to write up the rest of the script. The subsector UWP list generator will also compute the temperature for internal purposes, but doesn’t print it because it’s not part of the UWP.
I decided that systems with code Amber and piratets are considered code Red. The rules just say that “Red codes are given out at the discretion of the Referee.”
The cool thing is that you can paste & copy the resulting list into the map generator and generate the map to go along with it.
Today I had to make the following change to Oddmuse because that fixes an image upload issue on my dad’s blog. What’s going on? He’s using the following:
Any ideas? The net result was that <$file> resulted in no content if run within the eval block.
*** wiki.pl.~1.925.~ Fri Jul 3 11:23:01 2009
--- wiki.pl Tue Aug 4 00:20:26 2009
***************
*** 3548,3554 ****
$type = $q->uploadInfo($filename)->{'Content-Type'};
ReportError(T('Browser reports no file type.'), '415 UNSUPPORTED MEDIA TYPE') unless $type;
local $/ = undef; # Read complete files
! eval { require MIME::Base64; $_ = MIME::Base64::encode(<$file>) };
$string = '#FILE ' . $type . "\n" . $_;
} else {
$string = AddComment($old, $comment) if $comment;
--- 3548,3555 ----
$type = $q->uploadInfo($filename)->{'Content-Type'};
ReportError(T('Browser reports no file type.'), '415 UNSUPPORTED MEDIA TYPE') unless $type;
local $/ = undef; # Read complete files
! my $content = <$file>; # Apparently we cannot count on <$file> to always work within the eval!?
! eval { require MIME::Base64; $_ = MIME::Base64::encode($content) };
$string = '#FILE ' . $type . "\n" . $_;
} else {
$string = AddComment($old, $comment) if $comment;Comments on 2009-08-03 Strange Perl Issue
This sounds like the issue we have on EmacsWiki as well.
– AaronHawley 2009-08-04 07:39 UTC
Thanks for the reminder! I had forgotten about it. 
– AlexSchroeder 2009-08-04 09:03 UTC
Does anybody read these at all? I need to write things down so I won’t forget. I’m trying to install XML::Parser and running into a tiny. I need to run it as root using sudo because I can’t install it using my ordinary account. I hate this and try to remedy the situation once a year. 
So it’s that time of the year again. I look at the o conf output and can’t find the place where I get to say I want to use sudo make install command. I’m also greeted by the following message when I start the CPAN shell, so I’m guessing this could be part of the problem:
There's a new CPAN.pm version (v1.9402) available! [Current version is v1.7602]
I’m trying to run sudo cpan Bundle::CPAN to see where that takes me… I actually had to run it several times (three? four?) but it worked in the end. Amazing.
Here I am trying to send mail using some Perl module. But most of them seem to be written for the last millenium. They work best with a local SMTP host. For my own needs, that no longer works. The webhost doesn’t have a sendmail binary available. The SMTP hosts I can reach require SSL and TLS authentication. Now I’m slowly digging into MIME::Entity, Mail::Internet, Mail::Mailer, Net::SMTP, Net::SMTP::SSL, Net::SMTP::TLS…

After experimenting with the four or five mail accounts I have access to, I was finally able to get the following to work:
my $from = 'kensanata@gmail.com'; my $to = $from; my $host = 'mail.epfarms.org'; my $user = 'alex'; my $password = '*secret*'; use MIME::Entity; my $mail = new MIME::Entity->build(To => $to, From => $from, Subject => 'test', Path => '/Users/alex/test.html', Type => 'text/html'); use Net::SMTP::TLS; my $smtp = Net::SMTP::TLS->new($host, User => $user, Password => $password, Debug => 1); $smtp->mail($from); # sender $smtp->to($to); # recipient $smtp->data; $smtp->datasend($mail->stringify); $smtp->dataend; $smtp->quit;
Comments on 2009-06-06 Spam Makes Sending Mail Harder
Well, theoretically at least it should now be possible to subscribe to comment pages!
– AlexSchroeder 2009-06-06 16:43 UTC
Guess not, because the webhost doesn’t have Net::SMTP::TLS installed. 
– AlexSchroeder 2009-06-06 16:58 UTC
I think it works after all! Luckily I wrote my script such that it gets the page content and subscriber list via ordinary HTTP requests, so the cron job that sends out emails can run anywhere on the net. This one is running on a server hosted by Eggplant Farms.
– AlexSchroeder 2009-06-07 13:25 UTC
Things to do for Oddmuse:
– Alex
Can it recognize new WikiWords as “ÖlPlattform”, thanks to change regular expression to match them?. As far I can understanding it a little, does it need change those regex and changes way of read (write?), string (from url, for instance) and files?
– JuanmaMP 2012-07-22 01:16 UTC
Actually, I think that a simple change of the regular expressions is all that is needed.
– AlexSchroeder 2012-07-22 05:11 UTC
Add Comment