Colin Johnstone wrote:
> 
> Gidday from Downunder,

Hello,

> Im writing the script to read the the contetns of a text file into a hash,
> the text file has two records
> 
> [EMAIL PROTECTED]|html
> [EMAIL PROTECTED]|txt

Hash keys have to be unique so the key "[EMAIL PROTECTED]"
can either have the value "html" or "txt" but not both.


> My script is below
> 
> open IN, "<$mailinglist";
> while( my $record = <IN> ){
>   @data = split( /\|/, $record);
>   $records{$data[0]} = $data[1];
> }
> close IN;
> 
> while(($k,$v)=each(%records)){
>   print"$k => $v<br>";
> }
> 
> all that gets stored in the hash is the last record how do I get all records stored 
>in the hash


my %records = do { local $/; split /\||\n/, <IN> };

OR

my %records = map { chomp; split /\|/ } <IN>;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to