Whoops, sorry.  Name's Robert

The problem even with doing redundent things is that the dedundency's didn't
clean up the extra white spaces in each line.

I glob in the whole file, bad, I know, but it's what I know and what works,
it also gives no overhead on the server and the script takes less then 30
seconds to download, parse the file 5 different ways, do some character
mappings, and other fun stuff.

Here's an original line:
         AA-1251     |12"X500 ALUMINUM FOIL (HVY) EA|     24.76 |     16.19
|     15.79 |     15.40 |U5|ALCAN |     8.000 |     5.000 |     9.000 |B 

Here's the line before the cleaning:
5|         AA-1251     |12"X500 ALUMINUM FOIL (HVY) EA|     24.76 |    
16.19 |     15.79 |     15.40 |245|3|     8.000 |     5.000 |     9.000 |B 
|         AA-1251     

Here's the same line after the script:
5| AA-1251 |12in. X500 ALUMINUM FOIL (HVY) EA| 24.76 | 16.19 | 15.79 | 15.40
|245|3| 8.000 | 5.000 | 9.000 |B | AA-1251


Here's the cleanup script as it stands right now.  The problem with the file
that comes out is leading white space after each |

sub cleanup{

use strict;

my $file = "/home/web/sales/info/bad.sql";
my $newfile = "/home/web/sales/info/inventory.sql";
my $line;

        open (OLDFILE, "< $file");
        open (NEWFILE, "> $newfile");
        while ($line = <OLDFILE>)  {
#               $line = $line =~ /^\s*(.*)\s*\n$/;
                $line =~ s/^ //mg;
                $line =~ s/ $//mg;
                $line =~ s/\t/|/mg;
                $line =~ s/\s+/ /mg;
                $line =~ s/^\s*//mg;
                $line =~ s/\s*$//mg;
                $line =~ s/\s*$//mg;
###  The following lines mod the files to reflect inches and feet
###             $line =~ s/"/in./mg;
###             $line =~ s/'/ft./mg;
                $line =~ s/(?<=\d)"/in. /mg;
                $line =~ s/(?<=\d)'/ft. /mg;

                print NEWFILE "$line\n";
        }
        close OLDFILE;
        close NEWFILE;
        
  print "$newfile has now been created\n";
}

TIA!

Robert

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to