If you
use strict; use warnings;
you would have spotted most of the issues yourself.
$amastringsentback3=@amagotback[0];
would be better written as:
$amastringsentback3=$amagotback[0];
but that still would not work, because the array @amagotback is not exported by the module, so it would use a package variable in main.

The following:
use warnings; use strict; use LWP::Simple; use LWP::Simple qw( $ua get ); use LWP::UserAgent; use HTTP::Request::Common qw(POST); #use Price_calc; use Price_calc qw(@amagotback $amastringsentback1 $amastringsentback2 +@amaglobal $amastringsentback); my $amastringsent = 'hello module'; Price_calc::get_ama($amastringsent); # And then some attempted trys to + get value returned by Price_calc::get_ama $amastringsentback1=$Price_calc::amastringsentback; $amastringsentback2=shift; #$amastringsentback3=@amagotback[0]; my $amastringsentback3=$amagotback[0]; print "DATA: $amastringsentback - $amastringsentback1 - @amaglobal - +$amastringsentback3 - $Price_calc::amastringsentback" ; ----------------------------------- package Price_calc; use LWP::Simple; use LWP::Simple qw( $ua get ); use LWP::UserAgent; use HTTP::Request::Common qw(POST); use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our (@amagotback, $amastringsentback1, $amastringsentback2, @amaglobal +, $amastringsentback); our @EXPORT_OK = qw(@amagotback $amastringsentback1 $amastringsentback +2 @amaglobal $amastringsentback); sub get_ama { #do stuff ## THE CODE WORKS FINE JUST WONT REUTRN VALUES. $amastringsentback = 42; #@amagotback[0]=$amastringsentback; $amagotback[0]=$amastringsentback; return $amastringsentback; } 1;
prints:
DATA: 42 - 42 - - 42 - 42

In reply to Re: Returning the value generated in package/module problem by cdarke
in thread Returning the value generated in package/module problem by Monkomatic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.