Re: sort and count match in file

2012-04-15 Thread Dr.Ruud
On 2012-04-16 07:58, Shekar wrote: next if (/^\s$/); You probably meant: next if /^\s*$/; # skip blank lines -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: sort and count match in file

2012-04-15 Thread Uri Guttman
On 04/16/2012 01:58 AM, Shekar wrote: if( exists $hash_val{$dom} ) { my $val=$hash_val{$dom}; $val++; $hash_val{$dom}=$val; } else { $hash_val{$dom}=1; } all that code can be replaced with this one line: $hash_val{$dom}++ ; pe

Re: sort and count match in file

2012-04-15 Thread Shekar
Below code might be helpful... Assuming you are passing log file as argument 1, and your values in log file are space delimited, use Data::Dumper; open my $fd, "<", "$ARGV[0]" or die $!; while(<$fd>) { next if (/^\s$/); my ($some_date, $some_time, $dom, $crt, $home)=split; i

Re: sort and count match in file

2012-04-15 Thread John W. Krahn
Вячеслав Агапов wrote: Hello all. Hello, I have a file with logs 2012-04-13 17:06:10,881 test:dom1 CRIT home 2012-04-13 17:06:10,882 work:dom1 CRIT home 2012-04-13 17:06:10,882 my:dom1 CRIT home 2012-04-13 17:06:10,881 test:dom2 CRIT home 2012-04-13 17:06:10,882 work:dom2 CRIT home 2012-04-1

Re: sort and count match in file

2012-04-15 Thread Shawn H Corey
On 12-04-15 01:44 PM, Вячеслав Агапов wrote: #!/usr/bin/perl use strict; use warnings; use diagnostics; use 5.010; use IO::Compress::Gzip; use IO::Uncompress::Gunzip; my %count = (); my $file = "log.gz"; my $ungzip = new IO::Uncompress::Gunzip($file); @arr = grep/work/,<$ungzip>; foreach

sort and count match in file

2012-04-15 Thread Вячеслав Агапов
Hello all. I have a file with logs 2012-04-13 17:06:10,881 test:dom1 CRIT home 2012-04-13 17:06:10,882 work:dom1 CRIT home 2012-04-13 17:06:10,882 my:dom1 CRIT home 2012-04-13 17:06:10,881 test:dom2 CRIT home 2012-04-13 17:06:10,882 work:dom2 CRIT home 2012-04-13 17:06:10,882 my:dom2 CRIT home 201