F
friend.05
Hi,
I am trying to analyze some data. I have big data files.
I have 3 different files in following format. ($file_1, $file_2,
$file_3)
ID | Time | IP | Code
Following is psuedo code which I am writing. I want to know another
efficient way to do same thing.
open(INFO_1,$file_1);
open(INFO_2,$file_2);
open(INFO_3,$file_3);
@file1_lines = <INFO_1>;
@file2_lines = <INFO_2>;
@file3_lines = <INFO_3>;
foreach $file1_line (@file1_lines)
{
@file1 = split('\|',$file1_line);
#some code
foreach $file2_line (@file2_lines)
{
@file2 = split('\|',$file2_line);
#some code
#if condition between File1 data and File2 data
{
#some code
foreach $file3_line (@file3_lines)
{
@file3 = split('\|',$file3_line);
#some code
#if condition
}
}
}
}
So I am going thorugh each data of file 1 and depending on if data is
present in file2 and again depending on some if condition I look for
that data in file3.
So each data of file1 will have to go through each data of file2 and
each data of file2 will have to go thorugh file3.
So this code is taking lot of time. I want some suggestion for
efficient code.
Can I use Hash Array (by reading file in hash array)
Thanks
I am trying to analyze some data. I have big data files.
I have 3 different files in following format. ($file_1, $file_2,
$file_3)
ID | Time | IP | Code
Following is psuedo code which I am writing. I want to know another
efficient way to do same thing.
open(INFO_1,$file_1);
open(INFO_2,$file_2);
open(INFO_3,$file_3);
@file1_lines = <INFO_1>;
@file2_lines = <INFO_2>;
@file3_lines = <INFO_3>;
foreach $file1_line (@file1_lines)
{
@file1 = split('\|',$file1_line);
#some code
foreach $file2_line (@file2_lines)
{
@file2 = split('\|',$file2_line);
#some code
#if condition between File1 data and File2 data
{
#some code
foreach $file3_line (@file3_lines)
{
@file3 = split('\|',$file3_line);
#some code
#if condition
}
}
}
}
So I am going thorugh each data of file 1 and depending on if data is
present in file2 and again depending on some if condition I look for
that data in file3.
So each data of file1 will have to go through each data of file2 and
each data of file2 will have to go thorugh file3.
So this code is taking lot of time. I want some suggestion for
efficient code.
Can I use Hash Array (by reading file in hash array)
Thanks