473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Return a value from sub script to main script in Perl

Hi all,

I have a main script MAIN.pl
I want to call all my five subscripts :
SUBSCRIPT1.pl
SUBSCRIPT2.pl
SUBSCRIPT3.pl
SUBSCRIPT4.pl
SUBSCRIPT5.pl
to may main script MAIN.pl . All this script will have a return value like true or false . depending on this input " if all the subscripts pass then we have to print pass to the Main script ".

I am new to perl . Please help me in this .

Main program :::

Expand|Select|Wrap|Line Numbers
  1.     use strict;
  2.     use warnings;
  3.  
  4.     my $result = 'fail'; 
  5.     print "How old are you? ";
  6.     my $age = <STDIN>;
  7.     if ($age < 13) {
  8.     print "You are too young for this\n";
  9.     print $age;
  10.     $result = 'pass';
  11.  
  12.     exit ;
  13.     }
  14.  

one such subscript :

Expand|Select|Wrap|Line Numbers
  1.     use strict;
  2.     use warnings;
  3.  
  4.    # my $scar = system "perl script.pl";
  5.    my $scar = `perl script.pl`;
  6.     print " $scar \n";
  7.  
Here it is not printing the output as true for $scar.
Jul 2 '14 #1
1 1222
RonB
589 Expert Mod 512MB
Please use the code tags whenever you post any code. I added them for you here, but please remember to use them in the future.

Your "main.pl" script isn't calling the "subscript", unless you reversed those examples in your post.

A better approach would be to convert each of those "subscript" scripts into subroutines and call each sub as needed. If you want, those subs could be defined in a separate (.pm module) file which is loaded via a use statement.

Additionally, instead of having the "subscripts" output "pass" or "fail", they should output (or via a return statement) send back 1 or 0 which is the numerical equivalent of indicating true/false pass/fail.
Jul 2 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dan | last post by:
hi ng, i want to give the invoker of my application information whether application has passed successfully. it shall get scheduled, and if the exeution did not pass, it should be repeated some...
25
by: Christian Christmann | last post by:
Hi, the ANSI-C 99 standard specifies that the main function has "int" as return type. However, there are still lots of people declaring "void" as main return type. Did previous ANSI-C...
2
sanjay123456
by: sanjay123456 | last post by:
Dear Friend , in c the return value for main() is optional why in c++ the main() must return value ? sanjay
1
by: apksaro | last post by:
if we use the following program int main() { /* some code */ return(1); } once the program completes its exicution the 1 is returned.
2
by: PrabhuSundar | last post by:
Is there any way to catch the integer retrun value of the main(). Could you explain with the program flow?
11
by: polas | last post by:
Good afternoon all, I appreciate that the standard requires that main should return an integer. What I was wondering though is there any accepted standardisation on exactly what value to return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.