use IO::Handle; use File::Temp; use File::Spec; use autodie; my $file = $ARGV[0]; my $temp = File::Temp->new(DIR => File::Spec->curdir); open my $fh, '<', $file; while ( my $line = $fh->getline ) { if ( $fh->input_line_number % 2 ) { $temp->print($line); } } close $fh; rename $temp->filename, $file;