The most common way is to open a pipe to the shell. This is especially useful if you want to type/send multiple lines to the shell. In this example we will launch the UNIX application sendmail to send an insulting email to a big company:
01: $sendmail_location = '/usr/sbin/sendmail';
02: # NOTE THAT THIS VARIES FROM SYSTEM TO SYSTEM
03:
04: $subject = 'I DO NOT LIKE HFC !!!!';
05: $sender = 'PERL BEGINNER <perlstarter\@netikus.net>';
06: $recipient = 'COCA COLA <office\@cocacola.com';
07: # PERL REQUIRES A PRECEEDING BACKSLASH BEFORE THE @ CHARACTER !!
08:
09: open (MAIL,"|$sendmail_location -t");
10: # YOU CAN WRITE ANYTHING INSTEAD OF MAIL, THIS IS THE SO CALLED FILEHANDLE
11: # -t IS AN OPTION OF SENDMAIL
12: print MAIL "To: $recipient\n";
13: print MAIL "From: $sender\n";
14: print MAIL "Subject: $subject\n\n";
15: print MAIL "After I heared that Coca Cola is using HFC in their cooling machines \n";
16: print MAIL "worldwide even though there is a GREEN alternative, I stopped drinking all \n";
17: print MAIL "beverages from the CocaCola company. Thank you for taking part in the \n";
18: print MAIL "destruction of the OZON layer.\n";
19:
20: close(MAIL);
21: # THE FILEHANDLE IS CLOSED AND WE ARE DONE ! BRAVO !