Why use regex when there is a module to do this for you?
#!/usr/bin/perl
use strict;
use warnings;
use Text::CSV;
my $csv = Text::CSV->new ({ sep_char => '|' });
while (<DATA>){
my $line = $_;
chomp;
next if (/Order/);
print ("string $_ \n");
$_ =~ s/\"//g;
my @array = split /\|/ ;
print("order $array[0] , wrong sometimes $array[3]\n");
my $status = $csv->parse($line);
my @columns = $csv->fields();
print("order $columns[0] , right $columns[3]\n\n");
}
__DATA__
"129822"|"Custom Currency"|"Living the | Dream"|"400"
"129823"|"Custom Currency"|"Living the Dream"|"500"
Outputs:
string "129822"|"Custom Currency"|"Living the | Dream"|"40
order 129822 , wrong sometimes: Dream
order 129822 , right 400
string "129823"|"Custom Currency"|"Living the Dream"|"500"
order 129823 , wrong sometimes: 500
order 129823 , right 500
The questions isn't is someone likely to put that pipe dream in there, the question is if you should
ever have to care if they do!