On Jul 7, madhurima das said:
#assign.pl#
#!/usr/bin/perl
use strict;
use warnings;
print "enter the first number\n";
my $x = <STDIN>;
chomp $x;
print "enter the second number\n";
my $y = <STDIN>;
chomp $y;
my $z = system("assign.f",'$x','$y');
Many things wrong here:
1. system() does NOT return the OUTPUT of the program it runs (see the
docs: perldoc -f system)
2. you have single quoted $x and $y, which means they are simply the
strings $x and $y -- you wanted Perl's values for those variables
3. you're calling assign.f, instead of a.out
4. assign.f reads its values from STDIN, not from the commandline
Assuming you have compiled assign.f to a.out, I would do the following:
use IPC::Open2;
open2 my($read), my($write), "./a.out"
or die "can't open2 ./a.out: $!";
<$read>; # read (and discard) a line of output
print $write "$x\n";
<$read>; # read (and discard) the next line of output
print $write "$y\n";
chomp(my $z = <$read>); # read (and save) the next line of output
close $read;
close $write;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>