On Nov 12, Rob Dixon said: ><[EMAIL PROTECTED]> wrote: >> >> I have this written in the script to parse it: >> while ($line = <OLDFILE>) { >> # $line = $line =~ /^\s*(.*)\s*\n$/; >> $line =~ s/^ //; >> $line =~ s/ $//; >> $line =~ s/\t/|/g; >> $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; > > while (<OLDFILE>) { > > s/\t/|/g; # change tab separators to pipes
I'd use tr/\t/|/, and add a chomp() before-hand. > s/^\s+//; # remove all leading space > s/\s+$//; # and trailing space > s/\s+/ /g; # and compress multiple spaces I'm assuming by \s we're really just expecting tabs and spaces, but I'll include carriage returns and formfeeds. I'd be tempted to change these THREE regexes: # pick ONE of the following TWO: tr/\r\t\f / /s; # squashes consecutive [\r\t\f ]'s to a single space # or s/\s+/ /g; # then do both of the following: s/^ //; # remove a SINGLE leading space s/ $//; # remove a SINGLE trailing space -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]