bofinken has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I don't want the subroutine in a module write the string value. I want to do it in my main program. That seems easy and logical, but I can't get it working.

My value is in a subroutine that I am calling, so far so good, but I want to continue pass it over to my program. How do I do that?

Here is my module (with subroutine) and my main. This doesn't work... Thankful for help.

*********

my main program .pl:

use testarvilt(menskrivtillbaka); testarvilt::menskrivtillbaka("Hejhej"); print $dininput_len;

my .pm file:

package testarvilt; sub menskrivtillbaka { $dininput=@_[0]; print $dininput; $dininput_len = length $dininput; } 1;

2018-12-01 Athanasius added code and paragraph tags

Replies are listed 'Best First'.
Re: Get the string from the module
by tobyink (Canon) on Nov 28, 2018 at 15:49 UTC

    Module:

    package testarvilt; use strict; use warnings; sub menskrivtillbaka { my $dininput = $_[0]; print $dininput, "\n"; my $dininput_len = length $dininput; return $dininput_len; } 1;

    Main script:

    use strict; use warnings; use testarvilt; my $result = testarvilt::menskrivtillbaka("Hejhej"); print $result, "\n";
      May all good things come your way!
      Hooray!

      Thanks a lot!
Re: Get the string from the module
by karlgoethebier (Abbot) on Nov 28, 2018 at 15:50 UTC

    See Re: perl modules.

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re:Get the string from the module
by BillKSmith (Monsignor) on Nov 28, 2018 at 16:14 UTC
    The use of strict forces us to think about where variables should be declared. In this case, that may have been enough to solve the problem yourself.
    Bill