Hi again,
Sorry I think I missed the point (only just spotted the last 2 lines of the output).
Try substituting
for the following:
"$hash{$name} .= $words;" for "$hash{$name} = $words;"
Regards
Aim.
===================================================================
Aim wrote:
> Hi,
> I have run your script (no chnages) on your data and I get the following output, is
> this what you
> expected?
> Also check if the very first line of your script holds the usual (#!/usr/bin/perl
> -w).
>
> __START__
> N: VIRGINIA ABASCAL
> W: , M.A., is a freelance director and has directed more
> W: than 40 plays in theaters including Theatreworks, San Jose State Company, Asian
> American
> W: Theatre Company, Speakeasy Theatre, and Theatre Artists of Marin, where she was
> resident
> W: director for eight years, working with new plays. She has won Critics Choice, Bay
> Area Critics
> W: Circle, and Dean Goodman production awards.
> W:
> W:
> N: GENE ABBOTT
> W: , M.A., has worked in vocational and adult education since
> W: 1973. He has been department chair, lead teacher, mentor, and consultant, and is
> program
> W: manager for the Marin County Regional Occupational Program. He has taught in
> adult education,
> W: community college, and ROP. He has lectured throughout California on the topic of
> W: "Thinking Curriculum in Technica Education."
> W:
> HN: VIRGINIA ABASCAL
> HN: GENE ABBOTT
> HV:
> HV:
> __END__
>
> =======================================================================
> Pam Derks wrote:
>
> > Hi all,
> >
> > am struggling with this, and it must be the something simple but for the life of
> > me I don't see it.
> >
> > Am trying to build a hash table with:
> > instructor name and their biography
> >
> > I've tried just about everything, but I can't get the values to show...
> >
> > where am I going wrong?
> >
> > thanks, Pam
> >
> > snippet:
> > #!/usr/bin/perl -w
> > use strict;
> >
> > open(BIOS, "instructor.txt") or die ("no instructor file: $!");
> >
> > build_hash();
> >
> > sub build_hash{
> > my ($line, @name, @words, $key, $value, $name, $words);
> > my %hash = ();
> >
> > while(<BIOS>){
> > chomp;
> > if ($_ =~ /^[A-Z]{3,3}/){ #an instructor name
> > $name = $_;
> > $name =~ s/[ ]+$//; #remove trailing whitespace
> > print("N: $name\n");
> >
> > }
> > elsif ($_ !~ "XX"){
> > $words = $_;
> > $words =~ s/[ ]+$//; #remove trailing whitespace
> > print("W: $words\n");
> > }
> >
> > $hash{$name} = $words;
> >
> >
> > }
> >
> > foreach (keys %hash){
> > print("HN: $_\n");
> > }
> >
> > foreach (values %hash){
> > print("HV: $_\n");
> > }
> >
> > } #end build_hash
> >
> > close BIOS;
> >
> > sample data:
> > VIRGINIA ABASCAL
> > , M.A., is a freelance director and has directed more
> > than 40 plays in theaters including Theatreworks, San Jose State Company, Asian
> > American
> > Theatre Company, Speakeasy Theatre, and Theatre Artists of Marin, where she was
> > resident
> > director for eight years, working with new plays. She has won Critics Choice, Bay
> > Area Critics
> > Circle, and Dean Goodman production awards.
> > XX
> >
> > GENE ABBOTT
> > , M.A., has worked in vocational and adult education since
> > 1973. He has been department chair, lead teacher, mentor, and consultant, and is
> > program
> > manager for the Marin County Regional Occupational Program. He has taught in adult
> > education,
> > community college, and ROP. He has lectured throughout California on the topic of
> > "Thinking Curriculum in Technica Education."
> > XX
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]