A
A. Sinan Unur
(e-mail address removed) (Chris Page) wrote in [email protected]:
How come?
perldoc -f system
is a good place to start to find out how to call an external program.
In a Perl program, you can access command line arguments via @ARGV. It is
documented in perldoc perlvar.
Hmmmm ... I have lost count of how many times I asked the question "What
have you done so far?" just in the last two days.
The weather here is great, my office hours are over, I am feeling good,
etc etc, so I am just going to ask you to please read the posting
guidelines for the group, and take a look at the example below.
Remember, to research and try first, and then ask everyone else.
#! /usr/bin/perl
# t1.pl
use strict;
use warnings;
my $v = '4';
my $r = `perl t2.pl $v`;
chomp $r;
my $out = (($v eq $r) ? 'SUCCESS: ' : 'FAILURE ');
$out .= "Passed '$v' to t2, and received '$r'.\n";
print $out;
__END__
#! /usr/bin/perl
# t2.pl
use strict;
use warnings;
print "$ARGV[0]\n";
__END__
C:\asu1>perl t1.pl
SUCCESS: Passed '4' to t2, and received '4'.
Sinan
I'm trying to get one program to call another, passing it values.
Reading the documentation lets me know in multiple places that it
can be done, but I haven't found the specific syntax needed.
How come?
perldoc -f system
is a good place to start to find out how to call an external program.
In a Perl program, you can access command line arguments via @ARGV. It is
documented in perldoc perlvar.
More precisely, (writing in pseudocode), I'd like to be able
to do the following:
PROGRAM 1
Call program 2, forwarding the constant '4'.
End
PROGRAM 2
Print the value passed to it.
End
Hmmmm ... I have lost count of how many times I asked the question "What
have you done so far?" just in the last two days.
The weather here is great, my office hours are over, I am feeling good,
etc etc, so I am just going to ask you to please read the posting
guidelines for the group, and take a look at the example below.
Remember, to research and try first, and then ask everyone else.
#! /usr/bin/perl
# t1.pl
use strict;
use warnings;
my $v = '4';
my $r = `perl t2.pl $v`;
chomp $r;
my $out = (($v eq $r) ? 'SUCCESS: ' : 'FAILURE ');
$out .= "Passed '$v' to t2, and received '$r'.\n";
print $out;
__END__
#! /usr/bin/perl
# t2.pl
use strict;
use warnings;
print "$ARGV[0]\n";
__END__
C:\asu1>perl t1.pl
SUCCESS: Passed '4' to t2, and received '4'.
Sinan