#!/usr/bin/perl #this program was created by John teBokkel aka Tanj #the program is used to remove "[ebuild N ]" from #the dependency list from `emerge -p packageName > file.txt` #also it removes version information from the end of the ebuild name use strict; use FileHandle; our($garbage,$string,$file,$newfile); ($file, $newfile)=@ARGV; our($fhIn, $fhOut); if ($file) { $fhIn = new FileHandle "< $file"; die "no such file\nagr1 source agr2 destination\n" unless defined($fhIn); } else { $fhIn = new FileHandle; $fhIn->fdopen('STDIN',"r" ); } if ($newfile) { $fhOut = new FileHandle "> $newfile"; die "could not create file\nagr1 source agr2 destination\n" unless defined($fhOut); } else { $fhOut = new FileHandle; $fhOut->fdopen('STDOUT', 'w'); } while(<$fhIn>) { $garbage=s/\[(.*?)\]//; s/\-\d(.*?)\n//; $string=$_ . "\n"; if($garbage==1) { print $fhOut "$string"; } } $fhIn->close(); $fhOut->close();