Output:use Modern::Perl; <DATA>; while (<DATA>) { chomp; my ( $PID, $POLS, $U, $POOL_NAME, $Seq, $Num, $LDEV, $H, $VCAP, $T +YPE, $PM ) = / ^ (\d+) \s+ (.+?) \s+ (\d+) \s+ (.+?) \s+ (\d+) \s+ (\d+) \s+ (\d+) \s+ (\d+) \s+ ([^ ]+) \s+ ([^ ]+) \s+ ([^ ]+) $ /x; say join ';', ( $PID, $POLS, $U, $POOL_NAME, $Seq, $Num, $LDEV, $H, $VCAP, $TY +PE, $PM ); } __DATA__ PID POLS U(%) POOL_NAME Seq# Num LDEV# H(%) VCAP(%) TY +PE PM 003 POLN 0 Bad name with spaces 13453 2 61443 80 - OP +EN N 002 POLN 52 DemoSolutions 54068 7 61454 80 - OPEN N
003;POLN;0;Bad name with spaces;13453;2;61443;80;-;OPEN;N 002;POLN;52;DemoSolutions;54068;7;61454;80;-;OPEN;N
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial DeltronicsIn reply to Re: Regular Expression - delimiter/spaces problem
by CountZero
in thread Regular Expression - delimiter/spaces problem
by demichi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |