http://www.perlmonks.org?node_id=1009660


in reply to Problem with ampersand and regex

Always use use strict; use warnings;!

my $line = "mail: asdf@123.com";
should be
my $line = 'mail: asdf@123.com';

Then you can simply use

if (my ($mail) = $line =~ /mail: (.*)/) { print "mail=$mail\n"; }