0

test1.pl

#! /usr/bin/perl
print "enter the user data";
$var=<>;
print "the entered data:$var";

test2.pl

#! usr\bin\perl
$var=`test2.pl`;
print $var;

When executing test2.pl it doesn't work. How can it be solved?

1
  • 2
    You are calling test2.pl in test2.pl, why? What are you expecting from test2.pl? Commented Aug 21, 2015 at 13:04

1 Answer 1

1

Use require to execute the another program. Try this

test1.pl

print "enter the user data ";
chomp($var=<>);
print "the entered data:$var\n";

test2.pl

require "test1.pl";
print "$var\n";

Then easily access the $var from the test1.pl.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.