eval, ARGV

In a more realistic application information is exchanged between the two scripts. Suppose t1.pl sends arguments to t2.pl which returns a string with the results. Let's look at t2.pl first:

 
#
# this is t2.pl
#
print "t2.pl received @ARGV\n";
return "Guten Tag 7";

t2.pl receives its arguments via @ARGV. This array name has been choosen because it is @ARGV that imports the command line arguments in any Perl script.

The script t1.pl declares @ARGV and fills it with some contents:

#!/usr/bin/perl
#
# this is t1.pl
#
use strict;
{
    my @ARGV = qw( 3.14 "Hello"); 
    my @res = split ' ', eval `cat t2.pl`; 
    print "t2.pl returned @res\n";
}

@ARGV has been declared private to an anonymous block in order to avoid collisions with the @ARGV that passes arguments to t1.pl. The important line is my @res = split ' ', eval `cat t2.pl`;. It calls t2.pl and splits the returned string into pieces.

Running t1.pl yields:

$ perl t1.pl
t2.pl: received: 3.14 "Hello"
t2.pl returned Guten Tag 7