Quote:
|
Originally Posted by kshtoperl
So no one!!!!!!!!
|
Oh, waah. There aren't a lot of perl hackers (this is a database forum!), and I was away for a few weeks doing .50 cal gunnery at Fort Knox.
To answer your questions:
I think you could possibly do what you're trying to do with a simple open command. I don't have a mailer running on this 'puter, but let's say you're trying to do this: echo Stupid test | gzip -c | uuencode blah.gz
That's bash, here's what it looks like in Perl:
Code:
open FOO, "| gzip -c | uuencode blah.gz"; print FOO "Stupid test"; close FOO;
Since @data is an array, you might want to join it or something. I'll assume you mean to end each line with a newline.
Code:
open FOO, "| uuencode filename.csv | mailx --whatever";
print FOO "$_\n" for @data;
close FOO;
Second, if you can, you should install
Convert::UU from CPAN. You can then use this code:
Code:
use Convert::UU;
$encoded_string = uuencode(join("\n", @data), "filename.csv");
open FOO, "| mailx --whatever";
print FOO $encoded_string;
close FOO;
If you ever need to make your script more general and robust, you should look at
Mail::Transport:
end. They have a plugin for mailx.
Quote:
I tried the follwoing
qx { @data | uuencode file.csv | mailx -s "Reort" userid;
system ( @data | uuencode file.csv | mailx -s "Reort" userid);
|
As to why your code didn't work:
The qx stuff and system commands are only useful when you don't need to communicate with the program. If you do `@data | uuencode | ...`, what happens is that Perl expands @data and sends that to your shell. Your shell is expecting commands, not data, so it either crashes or tries to interpret them. (Good thing you didn't have rm -rf / in your data!)