G'day mariaprabudass,
Welcome to the Monastery.
The output I get is 'Hello\'; not the '"**Hello**"' you show.
What you actually want to split on is a pipe (|) that is not preceded by a backslash (\). You can do this with, what is called, a negative look-behind assertion which looks like: (?<!PATTERN). See "perlre: Extended Patterns" for more details.
Both the pipe and backslash characters are special in regexes and need to be escaped. This gives a split pattern of /(?<!\\)\|/.
Here's my test code:
#!/usr/bin/env perl -l use strict; use warnings; my $id = 'Hi|Hello\|Sir'; my @code = split /\|/, $id; print $code[1]; @code = split /(?<!\\)\|/, $id; print $code[1];
Output:
Hello\ Hello\|Sir
— Ken
In reply to Re: Splitting the record using the delimiter
by kcott
in thread Splitting the record using the delimiter
by mariaprabudass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |