On Oct 6, 11:26 am, [EMAIL PROTECTED] (Jeff Pang) wrote: > > Message du 06/10/08 17:03 > > De : "[EMAIL PROTECTED]" > > A : [EMAIL PROTECTED] > > Copie à : > > Objet : data from file > > > Hi, > > > I have large file in following format: > > > ID | Time | IP | Code > > > Now I want to write script that will cluster data by IP addr. and > > count total number of IDs for corresponding IP. > > first I hope this is not a homework question. > you may try something like: > > my $hash = {}; > while(<DATA>) { > my ($id,$ip) = (split)[0,2]; > $hash->{$ip}->{$id} ++; > > } > > use Data::Dumper; > print Dumper $hash; > > Regards, > Jeff. > > Créez votre adresse électronique [EMAIL PROTECTED] > 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.- Hide quoted > text - > > - Show quoted text -
Thanks. No it is not homework. I trying to analyze some data. I am trying read file line by line and then use split('|',-------) But it is not getting split by delimeter " | " . Below is example code. But out is not as expected bcoz it is not getting split properly. I am not sure what I am doing wrong. open(INFO, $file); @lines = <INFO>; @line = split('|', $lines[0]); print $line[0]; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/