use strict;
use warnings;
use Data::Dumper;
my @subjects = split /, /, "foo, bar, baz";
my %lc_class;
$lc_class{PN} = \@subjects;
print Dumper \%lc_class;
####
use strict;
use warnings;
use Data::Dumper;
# a home for our results
my %lc_class;
# read data from the end of the script
# a handy testing tool
while (my $line = ) {
chomp $line; # remove newline
# split each line on =, optionaly surounde by space, max 2 parts
my ($class, $subj) = split /\s*=\s*/, $line, 2;
# split the subject on , (optional space)
my @subjects = split /\s*,\s*/, $subj;
# store a reference to the @subjects array
$lc_class{$class} = \@subjects;
}
# show and tell
print Dumper \%lc_class;
__DATA__
PN = this, that, the other
GN = something
RT = test with some space, testwithout, And more space
####
$VAR1 = {
'RT' => [
'test with some space',
'testwithout',
'And more space'
],
'PN' => [
'this',
'that',
'the other'
],
'GN' => [
'something'
]
};