Thursday, April 14, 2005

Why we have Perl

Because when Microsoft's awful Office package obfuscates how to maintain Excel formatting during a mail merge, you don't want to change a jillion entries by hand. There should be brackets around INFILE in the loop, but HTML gets me. I wonder how I escape brackets.

open (INFILE, "ChangemePerlGods.txt");
open (OUTFILE, ">faxes.txt");

while (INFILE)
{
(my $area,my $three, my $four) = $_ =~ /(\d{3})(\d{3})(\d{4})/;
my $fax = "($area) $three-$four\n";
print OUTFILE $fax;
}
close INFILE;
close OUTFILE;

1 comment:

JD said...

Ampersand lt; = bracket left
Ampersand gt; = bracket right
(I wrote out ampersand so it doesn't get turned into html. also, don't leave a space after the amp.)