How are you assigning @subjects to PN? Where does the value of $call come from?
use strict; use warnings; use Data::Dumper; my @subjects = split /, /, "foo, bar, baz"; my %lc_class; $lc_class{PN} = \@subjects; print Dumper \%lc_class;
Here is a more extensive example of splitting and storing...
Output: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 = <DATA>) { 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' ] };
Cheers,
R.
In reply to Re: Split Not Working Correctly?
by Random_Walk
in thread Split Not Working Correctly?
by Hans Castorp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |