Today, while writing a regex to match a prompt output in order to interact with a program through IPC::RUN, I came across an inexplicable failure in matching a simple regex.
$ perl -E 'say "OK" if "mbox user@testdomain.it> " =~ /mbox\s+.*@.*> /s'
$
$ perl -E 'say "OK" if "mbox user@testdomain.it> " =~ /mbox\s+.*@t.*> /s'
OK
$
I thought it could be a problem of interpolation of «@» as a sigil, but
$ perl -E 'say "OK" if "mbox user@testdomain.it> " =~ /mbox\s+.*\@.*> /s'
$
It’s so simple I can’t seem to understand where the problem may lie.
Perl version is 5.10.1 on an Ubuntu 10.4
Any ideas?
Thanks in advance
I think you were on the right track but looking at interpolation in the wrong place.
Consider what happens to the
@in your string rather than your regex.