in reply to return the output to the Parent script

system does not return the output of the called subprogram.

Use Backticks or qx if you want the output of a program:

my @output = `$cmd`;

Replies are listed 'Best First'.
Re^2: return the output to the Parent script
by Anonymous Monk on Sep 22, 2008 at 09:04 UTC
    I tried backticks also. It gives the following message and returns nothing.
    Err:<code> Can't return outside a subroutine at ..<\code>

      This has nothing to do with backticks. As you're not showing any code that reproduces the problem, I can't help you further. Maybe consider posting self-contained code that exhibits the problem.

      That error message mostly happens if you have a program like the following:

      #!/usr/bin/perl -w use strict; return 'Hello';

      So you must be doing that somewhere in your code.

        Yes I do.

        Sorry for not giving sufficient info.
        Here is my requirement.

        1.Call another(child) script which process a text file and return a value to the main script.

        I am calling the second script frm main like this.

         my $cmd=" perl C:\\ia\\getset_build_num.pl -mode get -p $outputname -t $build_num_template -c $build_num_config";
        In the second script, I capture the cmd input,exec subroutine and return the value to the main script. Problem arises when returning the value to main script. I am wrong when returning the value. if so what will be the correct value.

        if ($mode eq "get") { my ($bld_num,$message)= get_build_number($package,$config_file); return $bld_num; }else{ my ($set_status,$message) = set_build_number($package,$template,$c +onfig_file); return ($set_status,$message); }
        Thanks
      If you want to pass data around in perl data structures, turn your script into a module, then you can ordinarily return data from it.