J
joseph85750
I have a unix program called zathras which will generate some useful
output results when a file is piped into it.
ie:
cat /path/to/asci-file.txt | zathras
(this will output some text I wish to capture)
I'm trying to write a perl script to execute the above, but not from a
file piped in. Instead, a variable within the perl script, since the
asci-file.txt above will have changing content. Here's what I have so
far:
$someData="12 15 77 19 42 2112 99 88"; #data from asci-file.txt
open (FOO,"|zathras");
print FOO $someData;
close;
This works, and behaves exactly as running the program directly from
unix. But what I really want is to store the results in an array,
rather than printing.
I suspected I could do something like:
@array=<FOO $someData>;
But this does not work. The @array ends up empty, but no errors are
thrown.
Any help would be great.
Thanks!
output results when a file is piped into it.
ie:
cat /path/to/asci-file.txt | zathras
(this will output some text I wish to capture)
I'm trying to write a perl script to execute the above, but not from a
file piped in. Instead, a variable within the perl script, since the
asci-file.txt above will have changing content. Here's what I have so
far:
$someData="12 15 77 19 42 2112 99 88"; #data from asci-file.txt
open (FOO,"|zathras");
print FOO $someData;
close;
This works, and behaves exactly as running the program directly from
unix. But what I really want is to store the results in an array,
rather than printing.
I suspected I could do something like:
@array=<FOO $someData>;
But this does not work. The @array ends up empty, but no errors are
thrown.
Any help would be great.
Thanks!