in reply to Split Not Working Correctly?

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;

Update

Here is a more extensive example of splitting and storing...

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
Output:
$VAR1 = { 'RT' => [ 'test with some space', 'testwithout', 'And more space' ], 'PN' => [ 'this', 'that', 'the other' ], 'GN' => [ 'something' ] };

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^2: Split Not Working Correctly?
by Hans Castorp (Sexton) on Jan 08, 2014 at 16:16 UTC

    Nice! Thanks RW. I'm going to try to post an abbreviated form of the script so people can have a better idea of what it's doing. Still working on it, though.

Re^2: Split Not Working Correctly?
by Hans Castorp (Sexton) on Feb 06, 2014 at 17:23 UTC

    Hi RW, I just figured out there was a subroutine running that took out all duplicate records. Split was working as it should. ;-)

    Thank you so much for your help. I learn a lot each time I ask for help here.