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



In reply to Re: Gentoo Linux `emerge -p package >file` by Tomte
in thread Gentoo Linux `emerge -p package >file` by Tanj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.