viprsrevenge has asked for the wisdom of the Perl Monks concerning the following question:

I cannot locate the correct method for removing the values in my array so that I may re-use them as a variable later in my script. My example is a mac address that was converted to decimal form as individual values of the array. The below loop prints the format I need the value to be in.
for $regarray (@regarray) { print "$regarray = "; $reghex = hex($regarray); @decarray = $reghex; print ".".$reghex; }
How can this be solved?

Replies are listed 'Best First'.
Re: Array values to a decimal string?
by ig (Vicar) on May 29, 2011 at 04:06 UTC

    I don't understand your explanation of what you want to do. Maybe you could try expanding on your example to show how you want to use the variable(s) later in your script.

    Maybe what you want is to have the array @decarray contain the decimal values corresponding to the hex values in @regarray, in which case the following may be the solution you are looking for:

    for $refarray (@regarray) { print "$regarray = "; $reghex = hex($regarray); push(@decarray, $reghex); print "." . $reghex; }

    Or, you could try the map function:

    @decarry = map hex($_), @regarray;
Re: Array values to a decimal string?
by Anonymous Monk on May 29, 2011 at 02:30 UTC
    How can this be solved?

    How can what be solved? Have you read perlintro?