Perl system function syntax
Hey folks. I'm a noob and I have a very noob question. Feel free to flame me and tell me how easy this one is. I'm trying to perform the system function but I can't get the syntax correct.
Code:
system("emerge -up world | mail -s "RESULTS" $MAIL_ADDRESS"); Thanks in advance. |
You can
a) use backslash to escape the <"> (double quotes) characters system("emerge -up world | mail -s \"RESULTS\" $MAIL_ADDRESS"); b) use <'> (single quotes) system("emerge -up world | mail -s 'RESULTS' $MAIL_ADDRESS"); c) use a perl variable containing the subject (including double quotes) my $SUBJECT = q/"This is the subject of my mail ..."/; system("emerge -up world | mail -s $SUBJECT $MAIL_ADDRESS"); d) omit the quotes (only in your special case), as "RESULTS" does not contain any whitespace and should be perfectly ok :-) system("emerge -up world | mail -s RESULTS $MAIL_ADDRESS"); "There's More Than One Way to Do It" ... |
hehe thanks a lot. After posting this question I remembered something from my php book about using the backslash. I wondered if it worked in perl too. Well as you pointed out it does. Thanks man.
|
All times are GMT -5. The time now is 03:09 AM. |