$ cat t.pl #!/usr/bin/perl use strict; use warnings; my @array = ; foreach my $line (@array) { if ($line =~ /mail: /) { my $mail = substr($line, $+[$#+] ); print "mail=$mail\n"; } } __DATA__ This @ should be just fine mail: this @ should also be fine $ perl t.pl mail=this @ should also be fine