in reply to Gentoo Linux `emerge -p package >file`
Cool script! Thanks for sharing it.
Update:There are serious bugs in the open(...) statements in my code, I'm currently trying to get it to work, take it just as the (IMHO important) suggestion to allow pipes....
Update II:pod rules ok. I read a few module docs, and here is what I wanted in the first place.
A suggestion remains though, this is just a quick hack to show what I want: be able to pipe
(e.g. emerge -p world | this_prog.pl):
Here's the slightly changed code:
#!/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();
Again thanks, I'll use it here and there :)
regards,
tomte
|
|---|