/.../, m/.../, m#...#, m!...! and so on are all equivalent. The character following the m will be used to delimit the regexp.
Use
($reversed_name) = $string =~ m/\/(.*?)\|/;
if you prefer. It means the same thing, but it's not quite as readable.
foreach $string (
"s005219/Doe John|John.Doe\\",
"s0052194/Doe Thomas|Thomas.Doe\\",
) {
($reversed_name) = $string =~ m!/(.*?)\|!;
print($reversed_name, "\n");
}
# Prints
# ======
# Doe John
# Doe Thomas
Alternatively,
foreach $string (
"s005219/Doe John|John.Doe\\",
"s0052194/Doe Thomas|Thomas.Doe\\",
) {
if (m!/(.*?)\|!) {
print("$1\n");
}
}
|