in reply to Re: split function for | and \| delimiter
in thread split function for | and \| delimiter

Thanks for replying. I tried your idea but it didn't work. I got the output like

$str="9454958459|54|AWC XXX|B\|T\|MIN\|MAX\|Air Tree Reg 250 Min|Any(A +T)|455|9966004325|"; @arr=split /(?<!\\)\|/, $str; print "$_ \n" foreach(@arr);

and the output is

9454958459

54

AWC XXX

B

T

MIN

MAX

Air Tree Reg 250 Min

455

9966004325

Replies are listed 'Best First'.
Re^3: split function for | and \| delimiter
by toolic (Bishop) on May 25, 2012 at 19:22 UTC
    Use single quotes to prevent interpolation of $str:
    use warnings; use strict; my $str='9454958459|54|AWC XXX|B\|T\|MIN\|MAX\|Air Tree Reg 250 Min|An +y(AT)|455|9966004325|'; my @arr=split /(?<!\\)\|/, $str; print "$_ \n" foreach(@arr); __END__ 9454958459 54 AWC XXX B\|T\|MIN\|MAX\|Air Tree Reg 250 Min Any(AT) 455 9966004325

      Yes this works. Thanks for your help :)