in reply to File Manipulation - Need Advise!
use strict; use warnings; open(SOURCE,"test.txt")|| warn "Could not open\n"; my @data = <SOURCE>;#just fyi -- slurping is dangerous on very large f +iles close(SOURCE); my %filtered_data; foreach my $line_of_data (@data){ my @split_data_values = split(/\s/,$line_of_data); my $computer_name = shift(@split_data_values); $filtered_data{$computer_name} = "@split_data_values"; } open(RESULT,">test.out")|| warn "Could not open\n"; foreach my $computer (keys(%filtered_data)){ print RESULT "$computer $filtered_data{$computer}\n"; } close(RESULT);
|
|---|