ermai
ermai

Reputation: 51

how to send stdin into perl program by batch file?

I would like to process many file/ string into perl and do not wait stdin responded from batch file,.How would be the batch file?

for instance I have test.pl and the content is

my $o=<STDIN>;

print "$o\n";

my $c=<STDIN>;

print "$c\n";

And a batch file executes the test.pl with different stdin at any time

Consider that the functionality of the batch file would be

perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 

Then I wonder how to send the stdin into the test.pl.

Upvotes: 1

Views: 229

Answers (1)

Manu Mathew
Manu Mathew

Reputation: 487

Here you have to use @ARGV to receive data. It should be as follows :

my $o=$ARGV[0];

print "$o\n";

my $c=$ARGV[1];

print "$c\n";

You can execute the program as follows :

perl test.pl argument_1a argument_2a

You will get output as

argument_1a
argument_2a

Upvotes: 1

Related Questions