in reply to how to assign hash element value to scalar?
One is that, when (as I mentioned) you use strict; and use warnings;, you get:
Global symbol "$userid" requires explicit package name at x line 17. Global symbol "$password" requires explicit package name at x line 18. Global symbol "$projectid" requires explicit package name at x line 19 +. Global symbol "$ordertypeid" requires explicit package name at x line +20. Global symbol "$orderdateid" requires explicit package name at x line +21. Global symbol "$accountid" requires explicit package name at x line 22 +. Global symbol "$segcodeid" requires explicit package name at x line 23 +. Global symbol "$marketid" requires explicit package name at x line 24. Global symbol "$marketday" requires explicit package name at x line 25 +. Global symbol "$marketmonth" requires explicit package name at x line +26. Global symbol "$marketyear" requires explicit package name at x line 2 +7. Global symbol "$putcall" requires explicit package name at x line 28. Global symbol "$strikeprice" requires explicit package name at x line +29. Global symbol "$bs" requires explicit package name at x line 30. Global symbol "$quantity" requires explicit package name at x line 31. Global symbol "$orderprice" requires explicit package name at x line 3 +2. Global symbol "$entered_by" requires explicit package name at x line 3 +4. Global symbol "$resultid" requires explicit package name at x line 80. Global symbol "$resultdesc" requires explicit package name at x line 8 +1. Global symbol "$orderid" requires explicit package name at x line 82.
Of these, note that $resultid is defined within the if clause:
if ($response->{channel}->{error}->{errorid} == "") { # ... my $resultid = $response->{channel}->{result}->{resultid};\ # ... };
... so of *course* it's not going to be available outside of the block.
You're also trying to return from outside of a subroutine, as well as comparing a string using "==" in the if statement I referenced above (you should really either use eq for string comparisons, or change "" to the numeric 0).
Is this the whole code sample, or just part of it?And what happens when [id://jugdish114|you] add use strict; and use warnings; to it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to assign hash element value to scalar?
by jugdish114 (Initiate) on Nov 14, 2006 at 20:14 UTC | |
by liverpole (Monsignor) on Nov 14, 2006 at 20:28 UTC | |
by jugdish114 (Initiate) on Nov 14, 2006 at 22:05 UTC | |
by Hofmator (Curate) on Nov 15, 2006 at 07:42 UTC | |
by johngg (Canon) on Nov 14, 2006 at 23:01 UTC |