Some very discursive comments after a very brief inspection...
my @resilt = (); while (<fh>) { my @a = (); @a = &get_data_path_report ($_); my %seen = (); push (@result, @a); @result = grep { !$seen{$_}++ } @result; } shift(@result);
You seem to have used lexicals pretty consistently, but then undermined their use by not enabling strictures — and warnings for good measure. See warnings and strict. Add these two lines at the very start of your program
use warnings;
use strict;
and then fix all the errors and warnings.
push (@result, @a); @result = grep { !$seen{$_}++ } @result;
The push statement is redundant. The statement
@result = grep { !$seen{$_}++ } @a;
would have the same effect, and a further simplification would be to use List::MoreUtils::uniq as in
@result = uniq get_data_path_report();
alone, all other statements in the while-loop being needless.The statement
use List::MoreUtils qw(uniq);
must be added at the start of the script to import uniq. (The function get_data_path_report() does not need to have $_ passed to it because the function takes no arguments — as far as I can see by quick inspection.)
The function
could be re-written (untested)sub get_first_elements_of_string { my @a = (split (' ' ,"$_[0]")); return $a[0]; }
(see split for the LIMIT parameter) which will not change its effect, but may improve its performance.sub get_first_elements_of_string { my ($first) = split ' ', $_[0], 2; return $first; }
Updates:
In reply to Re: How to manage a big file
by AnomalousMonk
in thread How to manage a pattern matching & counting with big data file
by taj_ritesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |