[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] code reduction



Wow. I committed this on December 12, 2000:

my $eot = chr(4);    # Perl regex's can't see newlines, so cheat
temporarily.
$foliolines =~ s/\n/$eot/g;
my @foliolines = split //, $foliolines;
for (
   my $k = 130;                 # Start at character 130...
   $k < length($foliolines);    # Stop when done...
   $k += 272                    # Each folio line is 272 characters
long...
) {
   splice @foliolines, $k, 22, (split //, $apply_this_card_to_all);
}
$foliolines = join "", @foliolines;
$foliolines =~ s/$eot/\n/g;


Here's my new version:

$foliolines =~ s/(.{130}).{22}(.*?\n)/$1$apply_this_card_to_all$2/gs;


Laugh,

j
older and wiser?