Home > Archive > PERL CGI Beginners > September 2004 > Loading an array
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Shawn Sharp 2004-09-02, 8:55 pm |
| I need some help, I am running this code to load values into the
$ArrayofCompareHex [$g] array. Currently it is not working. The
$comparevalue gets the correct value but the value is not past into the
array. Here is a portion of my code. Any ideas
230 my $g =0;
231 for ($g = 0; $g < $mps; ++$g)
{
239 $value = hex($ArrayofInput [$g]);
240 $ArrayofInputHex [$g] = $value;
241 $comparevalue = hex($ArrayofCompare [$g]);
242 $ArrayofCompareHex [$g] =$comparevalue;
}
thanks in advance
| |
| David Greenberg 2004-09-02, 8:55 pm |
| I'm no expert, but if I were to do what it looks like you are trying
to do, I would use the following code:
my @ArrayofInputHex = map { hex($_) } @ArrayofInput;
my @ArrayofCompareHex = map { hex($_) } @ArrayofCompare;
One of the main benefits of this code is that when you use strict;
like you should, you don't have to worry about local variables inside
the loop.
Hope this helps,
David
On Wed, 1 Sep 2004 12:46:57 -0700, Shawn Sharp <shawns@xzuberant.com> wrote:
> I need some help, I am running this code to load values into the
> $ArrayofCompareHex [$g] array. Currently it is not working. The
> $comparevalue gets the correct value but the value is not past into the
> array. Here is a portion of my code. Any ideas
>
> 230 my $g =0;
>
> 231 for ($g = 0; $g < $mps; ++$g)
>
> {
>
> 239 $value = hex($ArrayofInput [$g]);
>
> 240 $ArrayofInputHex [$g] = $value;
>
> 241 $comparevalue = hex($ArrayofCompare [$g]);
>
> 242 $ArrayofCompareHex [$g] =$comparevalue;
>
> }
>
> thanks in advance
>
>
| |
| Wiggins d Anconia 2004-09-02, 8:55 pm |
| Your question may be better asked on beginners@perl.org since it isn't
really CGI related.
>
> I need some help, I am running this code to load values into the
> $ArrayofCompareHex [$g] array. Currently it is not working. The
> $comparevalue gets the correct value but the value is not past into the
> array. Here is a portion of my code. Any ideas
>
Do you have strict/warnings enabled? Where did $mps come from and what
does it contain?
http://danconia.org
>
>
> 230 my $g =0;
>
> 231 for ($g = 0; $g < $mps; ++$g)
>
>
>
> {
>
> 239 $value = hex($ArrayofInput [$g]);
>
> 240 $ArrayofInputHex [$g] = $value;
>
> 241 $comparevalue = hex($ArrayofCompare [$g]);
>
> 242 $ArrayofCompareHex [$g] =$comparevalue;
>
> }
>
>
>
> thanks in advance
>
>
>
|
|
|
|
|