in reply to Re: Re: How can I read a line of text from a file into an array?
in thread How can I read a line of text from a file into an array?

In that case (and you may already have this worked out) if you are building one great big hash, the main code would look something like:
open HANDLE, 'testhash.txt' or die "Can't open: $!"; my %hash; for my $data (<HANDLE>) { chomp $data; foreach my $pair (split /'/, $data) { next if $pair eq ''; next if $pair =~ /^,$/; my ($key, $value) = split /,/, $pair; $hash{$key} = $value; } } close HANDLE; # do stuff with entire hash here
Or if you are doing something with the hash line-by-line:
open HANDLE, 'testhash.txt' or die "Can't open: $!"; for my $data (<HANDLE>) { chomp $data; my %hash; foreach my $pair (split /'/, $data) { next if $pair eq ''; next if $pair =~ /^,$/; my ($key, $value) = split /,/, $pair; $hash{$key} = $value; } # do interesting things with one-line %hash here } close HANDLE;

Replies are listed 'Best First'.
Re: Re: Re: Re: How can I read a line of text from a file into an array?
by fenners (Beadle) on Jul 19, 2001 at 00:04 UTC
    Bless you Brother!