There are dozens of ways I imagine. I'd probably choose a lookahead: $line =~ s/\s+(?=\|)//g. Hrm, I just noticed there's space after one of them. A look-ahead is probably the wrong choice then. I'd probably choose $line =~ s/\s*\|\s*/\|/g instead — there may be a more efficient way though.
I won't guarantee it's use in a production environment though. I've never tested the above.
-Paul
In reply to Re: Extracting data from a pipe delimited text file
by jettero
in thread Extracting data from a pipe delimited text file
by mantra2006
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |