in reply to symbolic reference & loading hashes
( Update: Oh! you are trying to create symbolic reference. Read Why it's stupid to `use a variable as a variable name' for why that's unwise. Use a hash instead, and then you can use the hash slice I mention below. )
I don't know what you are trying to do, but I'll point out two problems with that statement.
You are assigning an array to a scalar.
${@Fld}=@test; ^ ^ | | scalar array
An array evaluated in scalar context returns its length, so the length of the array would be assigned.
${@Fld} doesn't make much sense. It looks like a dereference, but @Fld is not a reference. Since references are scalars, the dereference (${...}) expects a scalar value. @Fld evaluated in scalar context is its length, so ${@Fld} is ${2} aka $2.
Maybe you are looking for a hash slice?
my @test=(11,22,33,44); my %Fld; @Fld{'LCD','XCOORD','Y','Name'} = @test; print($Fld{Y}, "\n"); # prints 33
|
|---|