in reply to New Perl User Question

I'd like to suggest formatting more like this for your code.

Code formatting is a religious topic, so let me just walk around the topic gingerly by suggesting that you want to make the code as readable as possible so that it's easy to maintain, easy to document, and easy to debug. Never assume that once you write a piece of code you're never going to have to deal with it again. Unless it's a one-liner, you're probably going to have to go back to it.

sub ProcessFile { my $data=''; my $datalength=0; my $startchar=''; open (RAWFILE, "$processfilename") || die "cannot open: $!"; open (CLEANFILE, ">$cleanfilename") || die "cannot open: $!"; while (<RAWFILE>){ $rawfilelength++; $data = $_; $datalength = length($data); $startchar = ord($data); if ($startchar == $correctstartchar){ if($datalength == $correctstartlength){ chomp $data; chop $data; $data = reverse ($data); chop $data; $data = reverse ($data); }else{ next; } if (length($data) == $correctcleanlength){ print CLEANFILE "$data\n"; $cleanfilelength++; } }elsif ($datalength == $typedlength){ print CLEANFILE "$data"; $cleanfilelength++; }elsif ($datalength > $correctcleanlength) { my $datalengthtrack = $datalength; chomp $data; $datalengthtrack--; chop $data; $datalengthtrack--; $data = reverse ($data); while ($datalengthtrack > $correctcleanlength){ chop $data; $datalengthtrack--; } $data = reverse ($data); print CLEANFILE "$data\n"; $cleanfilelength++; }elsif ($datalength < $correctcleanlength) { next; } } close (RAWFILE) || die "cannot close $processfilename: $!"; close (CLEANFILE) || die "cannot close $cleanfilename: $!"; } print "\a"; exit(0);

--t. alex

"Of course, you realize that this means war." -- Bugs Bunny.