473,386 Members | 1,785 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,386 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 1221
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.