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

[MacPerl] MacPerl, Unix, Tabs and other unseen elements



MacPerl 5.1.3r2 on a Performa 5215, system 7.5.5.

I have a simple script that parses through a Eudora mailbox and makes a report.

I am using BBEdit 4.0.3 and the wonderful MacPerl BBEdit extensions.

The email comes to me via a unix perl script which formats the data like so:


String1\tString2

and so on.

However, sometimes the tabs are off in the final output and I can't find
tabs or runs of spaces in the raw text. I have tried to uses BBEdits zap
gremlins and grep searches to uncover what's causing this, but no luck.
Also some of the lines begin with indents.  I have BBEdits line feed
filters in place and have tried inserting line breaks.

Any help will be appreciated. My code is below:


#! perl

while (<>) {
        chop;
        next if /^$/;

#       if ($_ =~ /^(Yes|No)\b/i) {
#               &the_split($_);
#       }

        if (/^(How|Martial|First)/) {
                &the_split($_);
        }


}


# This section splits the questions into separate arrays
########################################################
foreach $list (@list) {
        if ($list =~ /^Martial/) {
                push (@martial, $list);
        }
}

foreach $list (@list) {
        if ($list =~ /^First/) {
                push (@Firsttime, $list);
        }
}

foreach $list (@list) {
        if ($list =~ /^How/) {
                push (@Find, $list);
        }
}
########################################################
#foreach $Find (@Find) { #Test to see if we have the data
#       print  "$Find\n";
#}

print "Practice Hall Reader Survey\n";

&format (@Firsttime);
&format (@Find);
&format (@martial);

#########################################################
sub format {
        my ($q, $a, @holder);
        foreach $_ (@_) {
                ($q, $a) = split (/=/, $_);
                #print  "$a\n";     #Use this to test for values
                $a =~ tr/A-Z/a-z/;
                push (@holder, $a);
        }

        foreach $a (@holder) {
                $n{$a}++;
        }

        print  "\n\n$q Answer Summary\n";
        print  "=" x 55 . "\n";
        foreach $_ (sort keys %n) {
                printf "%-45s   %4d\n",$_, $n{$_};
        }
        %n = " ";
        print  "\n\n";
}


sub the_split {
        my ($question, $response);
        if ($_ =~ m/(.*?:)\t?([\w\s]+)$/) {
                $question = $1;
                $response = $2;
        }
                if ($response eq undef) {
                        $response = "No response";
                }

        $_ = join ('=', $question, $response);
        push (@list, $_);
}










Darryl Caldwell             Oikiasuchou School
___________________________________________________
The Practice Hall: http://www.eznet.com/bravo/ph/ph.html
Myth & Martial Culture