G'day vkknava,
The first thing you need to do is read Perl Introduction for Beginners.
Now that you've (hopefully) read that, let's go through your code line-by-line.
- while(<DATA>)
-
There's no __DATA__ token.
Perhaps you're using the "Input File" you posted.
- ($keys, $date, $token, $server, $hour, $peak)= split;
-
That doesn't match your "Input File".
3rd column is "Hour" vs. 5th field is $hour.
"Input File" has 5 fields; you're splitting $_ into 6 fields.
- @th = $date;
-
You probably want: push @th, $date;
- if ($keys eq $filename)
-
You don't initialise $filename anywhere in your code.
Perhaps you meant: if (! defined $keys)
- switch ... case ... case ... else
-
What language is this?
You appear to be just inventing new syntax!
- $res{$keys}{$date}->{DATE}
- $res{DATE}{$hour}->{PEAK}
- $res{$date}{$hour}->{PEAK}
-
You haven't defined %res anywhere in your code.
Why the "->" between the 2nd and 3rd keys?
You don't have "->" between the 1st and 2nd keys.
Did you think it was doing something special in that position?
I'm going to stop there.
You have problems on every single line of code so far.
Fix what I've pointed out.
Fix the problems Perl tells you about (from the strict and warnings pragmata you'll be adding to your code).
You'll also want to move that subroutine definition out of the while loop!
If you need further help, please ensure you have read, and followed, the guidelines in "How do I post a question effectively?" before posting.