in reply to headache with arrays.
A few problems, and they're all in the "Perl will give you enough rope to hang yourself" category.... $x1 and $x2 are going to be set to the literal text "substr(20,1,3)" (for example... the 20 could be any number in the range of -180 and 180). Why would you want substr to appear as literal text?
$y1 is going to be set to the string value of the 2nd digit from the left of $i, extending for three digits to the right. That means when $i is negative, the minus sign is left off. When it's positive, the high-order digit is left off. The same problem applies to the $y2 assignment. *sigh*
$array = "array$underscore$x1......etc" looks to me like you're trying to create a symbolic reference. Don't bother, that is a road to madness. Use real references instead, or a hash whos keys are this concaucted name.
And if you did absolutely have to muck up your symbol table with symbolic references, the syntax would be ${$array}[$k] = $count;, though I'm telling you, that's not what you want to be doing in your early stages of Perl learning...and probably not even in the later stages either.
You can read up on Perl's references at perlref and perlreftut. String quoting interpolation is covered in perlop. And of course there's substr.
Dave
|
|---|