in reply to How to put email addresses in a variable and send mails via mailx command

Your problem is use of single-quotes which do not interpolate any variables ...

... '|/bin/mailx -s "Happy Birthday" $email' ...

... so reverse the quotes used: qq{|/bin/mailx ... $mail_addr}.

Replies are listed 'Best First'.
Re^2: How to put email addresses in a variable and send mails via mailx command
by AnomalousMonk (Archbishop) on Dec 24, 2015 at 17:45 UTC

    ... or use explicit string concatenation, which is messier IMHO, but should work just as well:
        open(MAILPIPE,'|/bin/mailx -s "Happy Birthday" ' . $email) or die "Can't open pipe $!";


    Give a man a fish:  <%-{-{-{-<

      but should work just as well:

      both versions are vulnerable to shell interpolation

        both versions are vulnerable to shell interpolation

        How so? Can you please give an example?


        Give a man a fish:  <%-{-{-{-<