Bakken, Luke wrote:
> Here's a quickie:
> 
> I need to create a hash index out of a string that looks like this:
> 
> loans:a_foo[0]
> 
> If I build the index like this:
> 
> $rec->{"loans:a_$fld[$i]"} = $tmp{$fld} || '';
> 
> perl thinks that $fld[$i] is an array element, which it isn't.
> 
> Here are two solutions I found:
> 
> $rec->{"loans:a_$fld" . "[$i]"} = $tmp{$fld} || '';
> $rec->{"loans:a_$fld\[$i]"} = $tmp{$fld} || '';
> 
> Are there any other ways? Just curious.

"loans:a_${fld}[$i]" also works. I like your second version above best.

$ perl -MO=Deparse,-q -e '"a_${fld}[$i]"'
'a_' . $fld . '[' . $i . ']';

$ perl -MO=Deparse,-q -e '"a_$fld\[$i]"'
'a_' . $fld . '[' . $i . ']';

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to