J
jan09876
Hi,
I try to learn perl by myself without any programming background. I
try to transform my DATA to
#title -fruit-#
orange => orange, carot,
red => apple, cherry, strawberry
#title -vegetables-#
green => cucumber
red => tomatoes
I keep on receiving this message Use of uninitialized value in join
or string at ./print.pl line 18, <DATA> line 8. and don't know what to
do to fix the problem.
#!/usr/bin/perl
use warnings;
use strict;
my $title = "#.*#";
my %hash;
while(<DATA>) {
chomp;
{
my($key,$val) = split(/\s*=>\s*/);
push(@{$hash{$key}},$val);
}
for my $key (sort keys %hash) {
print "$key => @{$hash{$key}}\n";
print $titles;
}
}
__DATA__
#title -fruit-#
orange => orange
orange => carot
red => apple
red => cherry
red => strawberry
#title -vegetables-#
green => cucumber
red => tomatoes
I try to learn perl by myself without any programming background. I
try to transform my DATA to
#title -fruit-#
orange => orange, carot,
red => apple, cherry, strawberry
#title -vegetables-#
green => cucumber
red => tomatoes
I keep on receiving this message Use of uninitialized value in join
or string at ./print.pl line 18, <DATA> line 8. and don't know what to
do to fix the problem.
#!/usr/bin/perl
use warnings;
use strict;
my $title = "#.*#";
my %hash;
while(<DATA>) {
chomp;
{
my($key,$val) = split(/\s*=>\s*/);
push(@{$hash{$key}},$val);
}
for my $key (sort keys %hash) {
print "$key => @{$hash{$key}}\n";
print $titles;
}
}
__DATA__
#title -fruit-#
orange => orange
orange => carot
red => apple
red => cherry
red => strawberry
#title -vegetables-#
green => cucumber
red => tomatoes