Hello Shlomi, thx for the help. I tried and it worked. however I have few confusions. I tried it two ways (one yours and one from another website) I am not sure what is different between the two approaches. I do not know can you explain pl?
from: http://www.tutorialspoint.com/perl/perl_modules.htm file: Mymodule.pm #!/usr/bin/perl package Mymodule; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); # IT WAS FAILING WITH my our @EXPORT = qw(myroutine); ... sub myroutine{ ... } .... file: perlscript.pl #!/usr/bin/perl use strict; use warnings; use Template; use Mymodule; my ($output)=myroutine($input); then used your method: and it worked, as expected. I am not sure what is the diff between two approaches? can you pl help explain? ty. file: Mymodule.pm #!/usr/bin/perl package Mymodule; use strict; use warnings; use parent 'Exporter'; our @EXPORT_OK = qw(myroutine); file: perlscript.pl #!/usr/bin/perl use strict; use warnings; use Template; use Mymodule qw(myroutine); my ($output)=myroutine($input); ----- Original Message ----- From: Shlomi Fish <shlo...@shlomifish.org> To: Rajeev Prasad <rp.ne...@yahoo.com> Cc: perl list <beginners@perl.org> Sent: Tuesday, October 9, 2012 11:33 AM Subject: Re: simplestic perl module 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/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/