in reply to Splitting the record using the delimiter
Above you told it to split on pipes. And what I get when I run it is "Hello\" which is split on pipes.
Are you trying to split on pipes except when preceded by a backslash? If so:
#!/usr/bin/perl use strict; my $id = 'Hi|Hello\|Sir'; my @code = split(/[^\\]\|/,$id); print $code[1]."\n";
Note: That since this now splits on a character followed by a pipe that $code[0] would be "H" and not "Hi". The short answer is you are looking for split to have a variable delimiter in this case. A pipe sometimes and no pipe at other times.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting the record using the delimiter
by graff (Chancellor) on Sep 30, 2015 at 23:30 UTC |