Hi Rajeev,

On Tue, 9 Oct 2012 08:54:31 -0700 (PDT)
Rajeev Prasad <rp.ne...@yahoo.com> wrote:

> I want to execute this routine which is to be supplied two(sometimes
> three) string variables. and will return two string variables. I want
> to keep this routine in a separate file. how to do it?
> 
> 
> 
> something like:
> 
> ($var1,$var2) = routine <arg1> <arg2>
> 
> I am either looking to keep this routine in a file which has many
> routines. OR to keep this routine in a separate file, which has ONLY
> this routine.
> 
> please suggest how to pass variables and accept the multiple values
> returned by the routine.
> 

Please see:

* http://perl-begin.org/topics/modules-and-packages/

for comprehensive info and tutorials about modules in Perl.

As a teaser, what you can do for example is:

[CODE]

# This is file MyModule.pm

package MyModule;

use strict;
use warnings;

use parent 'Exporter';

our @EXPORT_OK = qw(my_function);

sub my_function
{
        my ($first_s, $second_s) = @_;

        # Silly expressions:
        my $first_ret = $first_s . $second_s . "Hello";
        my $second_ret = $second_s . "Lambda" . $first_s;

        return ($first_ret, $second_ret);
}

1;

[/CODE]

And then do:

[CODE]
#!/usr/bin/perl

use strict;
use warnings;

use MyModule qw(my_function);

# Use my_function()
[/CODE]

But you really should learn about modules in Perl.

Regards,

        Shlomi Fish

> ty.



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

Knuth is not God! God has already released TeX version 4.0.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to