[Omaha.pm] code reduction

Jay Hannah jhannah at omnihotels.com
Thu May 10 14:54:09 PDT 2007


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?


More information about the Omaha-pm mailing list