On Wed, 2006-07-26 at 23:57 +0530, I BioKid wrote:
> One simple question -
> I need to accept a file from the user and to store it as temp1.
> then I need to give this file as an input of another program :
> I wrote a script like this, but it is not working : Help ?
>
> #!/usr/bin/perl -w
> use CGI;
> my $q = new CGI;
> my $file = $q->param('file');
> print $q->header();
>
> # Reading file from user and writing to another file temp1
> open (FOO, ">temp1");
> while (<$file>)
> {
> print FOO $_;
> }
> close FOO;
>
> # internaly executing xxx program; taking temp1 as input
> `/usr/bin/xxx temp1`;
>
> #temp.xxx is output of usr/bin/xxx
> @psa = `cat temp1.xxx`;
>
> foreach $i(@psa)
> {
> print "$i";
> print "<br>";
> }
I think that you may want to look up pipes. You can pass in data to a
program, have it process it and then get the output out from that
program without using an intermediate file.
I am curious why you wrote this:
>> @psa = `cat temp1.xxx`;
>>
>>foreach $i(@psa)
When you had this a little earlier in your code.
>>open (FOO, ">temp1");
>>while (<$file>)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>