perl camelfilter.pl # shows the llama
perl camelfilter.pl shark
perl camelfilter.pl gmax
####
+------------------+
| |
| while pattern |<------------------+ <-----------------+
| | | |
+------------------+ | |
| | |
V | |
/\ | |
/ \ +----------+----------+ |
/ \ | | |
/ is it\____NO_______> | write next non space| |
\ space/ | characters from | |
\ ? / | camel.pl | |
\ / +---------------------+ |
\/ |
| |
| |
YES |
| |
V |
+---------------------+ |
| write as many spaces| |
| as stated in the +------------------------------------+
| pattern |
+---------------------+
##
##
system "perl $newcamel | perl -ne 'print if !/^ ?mm|[\\^]{20}/'";
##
##
do "$newcamel";
##
##
#!/usr/bin/perl -w
# camelfilter.pl
use strict;
my $llama = "S51F11:S47F10S1F9:S45F21:S49F12:S49F9:S49F9:S49F9:"
. "S49F9:S49F9:S47F11:S3F8S4F26S4F13:S1F57:F57:F57:S2F54:S2F54:"
. "S3F51:S4F49:S4F48:S5F45:S6F17S3F23:S7F15S6F20:S8F13S10F16:"
. "S10F10S14F12:S11F8S17F10:S12F5S20F4S1F4:S12F4S21F4S2F3:"
. "S11F4S22F3S3F3:S12F3S22F3S3F3:S13F3S21F3S4F2:S13F5S20F3S3F3:"
. "S13F6S19F4S2F5:";
my $shark ="S46F9:S41F18:S8F24S5F3S1F21:F41S2F12:F7S2F33S3F9:"
. "S2F22S2F20S2F1S2F4:S4F20S3F22S1F4:S6F2S7F10S1F4S1F3S1F20:"
. "S11F2S7F14S1F1S1F15S1F3:S13F3S8F11S1F1S1F1S1F18:"
. "S14F7S6F6S1F1S2F21:S16F21S1F9S1F13:S19F20S1F3S2F2S1F13:"
. "S19F2S4F14S3F6S2F12:S17F7S9F6S1F2S3F4S1F13:S16F5S17F8S2F1S2F13:"
. "S16F1S26F21:S53F12:S48F3S5F9:S50F6S2F7:S52F12:S53F10:S54F6:"
. "S54F5:S53F4:S53F2:F1:";
my $gmax = "S65:S12F2S51:S11F4S50:S12F2S51:"
. "S5F4S3F2S1F5S3F2S4F2S8F3S7F7S3F5S1:"
. "S4F6S1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1F2S6F3S53:S2F3S3F4S53:S2F9S54:S3F7S55:S65:";
my $newcamel = "newcamel.pl";
my $oldcamel = "camel.pl";
open CAMEL, "< $oldcamel" or die "camel ($oldcamel) not found\n";
open NEWCAMEL, "> $newcamel"
or die "can't create new camel ($newcamel)\n";
my $camel;
while () {
print NEWCAMEL $_,next if /^(:?use|#)/;
chomp;
while (/(.)/g) {
$camel .= $1 if $1 ne " ";
}
}
close CAMEL;
my $out;
my $choice=shift;
my $pattern = \$llama;
if (defined $choice) {
$pattern = \$gmax if $choice eq "gmax";
$pattern = \$shark if $choice eq "shark";
}
else {
$choice = "llama";
}
my $camelcount =0;
while ($$pattern =~ /([SF:])([^SF:]*)/g) {
if ($1 eq "F"){
$out = substr ($camel, $camelcount, $2);
$camelcount += $2;
}
elsif ($1 eq "S"){
$out = " " x $2;
}
else {
$out = "\n";
}
print NEWCAMEL $out;
}
$out = substr($camel,$camelcount);
print NEWCAMEL $out;
close NEWCAMEL;
system "perl $newcamel | "
. "perl -ne 's/camel/$choice/;print if !/^ ?mm|[\\^]{20}/'";
#do "$newcamel";