You have a common precedence issue. Change the following line.
open FILE, $filename || die $!;
or if you really want to use ||
open FILE, $filename or die $!;
also it wouldn't hurt to be more verbose:
open(FILE,$filename) || die $!;
The usage of the \g modifier is for multiple matching,substituting,etc.
you don't need it if you know what you are searching for only occurs once
as is the case:
die "Could not open $filename: $!\n";
The original value of $from is "--from firstname.lastname@example.org \"
It wouldn't hurt to also have a look at perlop
$str =~s/a//g; # \g unnecessary
$str = 'abacad';
$str =~s/a//g; # more appropriate
-tengo mas que aprender