in reply to Re^3: how to change this code into perl
in thread how to change this code into perl

the file will be around 20000 rows and the first columns will always be text..

  • Comment on Re^4: how to change this code into perl

Replies are listed 'Best First'.
Re^5: how to change this code into perl
by poj (Abbot) on Aug 30, 2015 at 17:44 UTC
    #!perl use strict; use warnings; my $infile = $ARGV[0]; my $outfile = $ARGV[1]; open IN,'<',$infile or die "Could not open $infile : $!"; my %count = (); my @lines = (); while (<IN>){ push @lines,$_; if (/^(\S+)/){ ++$count{$1}; } } close IN; open OUT,'>',$outfile or die "Could not open $outfile : $!"; for (@lines){ if (/^(\S+)/){ print OUT $_ if $count{$1} > 1; } } close OUT;
    poj