Others have already answered your question, but nobody has mentioned that you don't need to use my @fields; in the third line of your code.
Your new method creates an array ref ($this) which contains a value whose key is fields. This hash element is independent of any other data structure in your code - it isn't connected to the @fields you have already declared.
In reply to Re: How do you add class array values
by tomhukins
in thread How do you add class array values
by daveman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |