You should avoid using capital letters in lexical variable names. They are reserved for global identifiers such as package names.
If you are trying to set up an array reference in the first place then you want something like this:
my $aces_1_key = [ qw[ NIL-RETURN ASSESSEE-NAME LTU MONTH RETURN-YEAR REGISTRATION-NUMBER ] ];
foreach my $key (@$aces_1_key) {
print $key, "\n";
}
output
NIL-RETURN
ASSESSEE-NAME
LTU
MONTH
RETURN-YEAR
REGISTRATION-NUMBER
Alternatively, if you have a string that you need to split into individual substrings then there are a few ways to. The program below shows one. It splits the string at the commas to produce a list of quoted substrings. Then the quotes are removed inside the loop using tr//. The output is identical to that of the previous example.
my $aces_1_key=("`NIL-RETURN`,`ASSESSEE-NAME`,`LTU`,`MONTH`,`RETURN-YEAR`,`REGISTRATION-NUMBER`");
foreach my $key (split /,/, $aces_1_key) {
$key =~ tr/`//d;
print $key, "\n";
}
$ACES_1_keysimply isn't an arrayref, therefore it can't be used as one, much like I cannot use a bicycle as an airplane. Do you want to parse that string into an array? This won't happen automatically. Either do it with regexes, or use the Text::CSV parser.my $ACES_1_key).