S
Steve
I am populating a hash from a text file
which consists of tab-delimited keys - values
Code fragment below
# if there is a file with titles, read it into hash
if (-e $image_file_path.$titlefile){
if (open (TITLEFILE, "<$image_file_path$titlefile")) {
while (<TITLEFILE>) {
chomp;
my @line = split /\t/;
$img_titles{$line[0]}=$line[1] || ' ';
}
}
}
It works, but I don't like it! Is there a way of putting the
products of the split straight into a hash without going via
an array ? One complication is the possibiity of a line in the
source file with no tab.
Thanks
Steve
which consists of tab-delimited keys - values
Code fragment below
# if there is a file with titles, read it into hash
if (-e $image_file_path.$titlefile){
if (open (TITLEFILE, "<$image_file_path$titlefile")) {
while (<TITLEFILE>) {
chomp;
my @line = split /\t/;
$img_titles{$line[0]}=$line[1] || ' ';
}
}
}
It works, but I don't like it! Is there a way of putting the
products of the split straight into a hash without going via
an array ? One complication is the possibiity of a line in the
source file with no tab.
Thanks
Steve