in reply to regexp, substitution and the "pipe symbol"

jockel: Peruse the following:

while (my $line=<DATA>) { chomp $line; $line =~ s/\s+\|/\|/g; # note the "g" on the end. printf "\"%s\"\n",$line; } __END__ B-52 |P-51 | P-61 P-48 |B-1B | JU-88 B-29 |ME-109

When run it yields:

"B-52|P-51| P-61" "P-48|B-1B| JU-88" "B-29|ME-109"

The secret is in the use of the "g" at the end of the regex with says "do this for every match"

Hope this helps.


Peter L. Berghold -- Unix Professional
Peter at Berghold dot Net
   Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.