you would have spotted most of the issues yourself.use strict; use warnings;
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.$amastringsentback3=$amagotback[0];
prints: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;
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |