There is following code in package "Insert.pm":my $i = 'Insert'; $i->dodaj_narzut($products_price, \%zakresy)
The problem is that in subroutine "dodaj_narzut" half of the time it's like hash reference doesn't exist. It skips while loop. Next time when subroutine is executed it works perfectly - it goes through while loop and returns proper "$wartosc". But if I uncomment "Use Data::Dumper" and "print Dumper($zakresy)" while loop is executed every time. When I resign on using references it also works OK every time. It must be something with the references.sub dodaj_narzut { my ($class,$cena,$zakresy) = @_; my $narzut = $class->ret_narzut($cena,$zakresy); my $new = sprintf('%.2f', $cena+($cena*($narzut/100))); return $class->zaokraglenie($new); } sub ret_narzut { my ($class,$cena,$zakresy) = @_; # use Data::Dumper; # print Dumper($zakresy); while (($zakres,$wartosc) = each %$zakresy) { my @zak = split '-', $zakres; if ($cena > $zak[0] and $cena <= $zak[1]) { return $wartosc; } } print "55\n"; return 55; }
In reply to Half of hash references are missing by jerzy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |