> Message du 08/10/08 12:56
> De : "[EMAIL PROTECTED]"
> A : beginners@perl.org
> Copie à :
> Objet : read file in hash array
>
>
> I want to ready file in Hash Array.
>
> I have file in following format:
>
> ID | Time | IP | Code
>
>
> open(INFO, $file);
>
> @lines = ;
>
> Instead of this I want to use Hash Array. May be just ID and IP fileds.
>


What's the special rule to creat the HoA you wanted?
If use IP as keys, ID as values, then do:

my %hash;
while(<INFO>) {
    my ($id, undef, $ip) = split/\|/;
    $id =~ s/^\s+|\s+$//g;
    $ip =~ s/^\s+|\s+$//g;

    push @{$hash{$ip}},$id;
}


Regards,
Jeff.

 Créez votre adresse électronique [EMAIL PROTECTED] 
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

Reply via email to