CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [alex5161] In a perl-script trying to execute another perl-script that SETS SOME VARIABLES for caller script: Edit Log



FishMonger
Veteran / Moderator

Mar 1, 2018, 4:52 PM


Views: 8894
Re: [alex5161] In a perl-script trying to execute another perl-script that SETS SOME VARIABLES for caller script

Here's a module example based on your code snippets.

script1.pl

Code
#!/usr/bin/perl 

use warnings;
use strict;
use MyModule qw( main_scr2 );
use Data::Dumper;

my @set_var = main_scr2('parm-1', 'parm-2');

print Dumper \@set_var;


MyModule.pm

Code
package MyModule; 

use strict;
use warnings;
use Exporter;

our @ISA = qw(Exporter);
our @EXPORT_OK = qw( main_scr2 );


sub main_scr2 {

my @input = @_;

# do something with @input

# return processed results
return ('val-1', 'val-2', 'val-3');
}

1;


Output

Code
c:\test>script1.pl 
$VAR1 = [
'val-1',
'val-2',
'val-3'
];



(This post was edited by FishMonger on Mar 1, 2018, 5:12 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Mar 1, 2018, 5:12 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives