Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[OT] Andere Programme von PERL aus benutzen
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2546
Location: Konradsreuth (Germany)

PostPosted: Tue Jun 14, 2005 4:35 pm    Post subject: [OT] Andere Programme von PERL aus benutzen Reply with quote

Ich hab mal eine Grundsätzliche Frage. Wie stell ich es an, in einem PERL-Script Programme wie oggdec oder lame, etc. zu benutzen, und den aktuellen Fortschritt zu bekommen? Also quasi das externe Programm läuft im Hintergrund und ich kann irgendwas mit dem Prozent-Wert in dem PERL-Programm machen.
Back to top
View user's profile Send private message
Deever
Veteran
Veteran


Joined: 06 Jul 2002
Posts: 1354
Location: Zürich / Switzerland

PostPosted: Wed Jun 15, 2005 6:17 am    Post subject: Reply with quote

Also in C würd ich popen() benutzen, vermutlich geht das in PERL ähnlich.

Gruß,
/dev
Back to top
View user's profile Send private message
Anarcho
Advocate
Advocate


Joined: 06 Jun 2004
Posts: 2970
Location: Germany

PostPosted: Wed Jun 15, 2005 7:13 am    Post subject: Reply with quote

Guck dir 5.15 an:

http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/part5.html#Q5.15

und lass die Umleitung von STDERR weg, dann sollte es möglich sein.
Ich habe es aber noch nicht versucht.
_________________
...it's only Rock'n'Roll, but I like it!
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2546
Location: Konradsreuth (Germany)

PostPosted: Wed Jun 15, 2005 11:37 am    Post subject: Reply with quote

Hmmm ... ich krieg's nicht hin. Wie ich den gesamten Output eines Programmes abfange, ist mir schon klar ... aber wie kann ich z.B. die prozentuale Fortschrittsanzeige von oggdec benutzen, während oggdec noch läuft?
Back to top
View user's profile Send private message
Mankale
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jan 2004
Posts: 76

PostPosted: Wed Jun 15, 2005 9:20 pm    Post subject: Reply with quote

bin kein Perl coder, aber ich würde versuchen stdout des externen Programms zu öffnen und dann Zeile für Zeile zu lesen.
So gehts zumindest in php
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2546
Location: Konradsreuth (Germany)

PostPosted: Tue Jun 28, 2005 8:32 pm    Post subject: Reply with quote

Das Problem war, daß die ganzen Zeilen mit prozent-Fortschritt als nur eine ausgelesen wurde. War daran gelegen, daß die Zeilenbegrenzung mit "\n" definiert war. Kann man auf "\r" umdefinieren, dann bekommt man alle Zeilen.
Back to top
View user's profile Send private message
Silicoid
Tux's lil' helper
Tux's lil' helper


Joined: 20 Jul 2004
Posts: 144
Location: Erde

PostPosted: Wed Jun 29, 2005 5:29 pm    Post subject: Reply with quote

Aus "perlvar":
Code:

       $INPUT_RECORD_SEPARATOR
       $RS
       $/      The input record separator, newline by default.  This influ-
               ences Perl's idea of what a "line" is.  Works like awk's RS
               variable, including treating empty lines as a terminator if set
               to the null string.  (An empty line cannot contain any spaces
               or tabs.)  You may set it to a multi-character string to match
               a multi-character terminator, or to "undef" to read through the
               end of file.  Setting it to "\n\n" means something slightly
               different than setting to "", if the file contains consecutive
               empty lines.  Setting to "" will treat two or more consecutive
               empty lines as a single empty line.  Setting to "\n\n" will
               blindly assume that the next input character belongs to the
               next paragraph, even if it's a newline.  (Mnemonic: / delimits
               line boundaries when quoting poetry.)

                   local $/;           # enable "slurp" mode
                   local $_ = <FH>;    # whole file now here
                   s/\n[ \t]+/ /g;

               Remember: the value of $/ is a string, not a regex.  awk has to
               be better for something. :-)

               Setting $/ to a reference to an integer, scalar containing an
               integer, or scalar that's convertible to an integer will
               attempt to read records instead of lines, with the maximum
               record size being the referenced integer.  So this:

                   local $/ = \32768; # or \"32768", or \$var_containing_32768
                   open my $fh, $myfile or die $!;
                   local $_ = <$fh>;

               will read a record of no more than 32768 bytes from FILE.  If
               you're not reading from a record-oriented file (or your OS
               doesn't have record-oriented files), then you'll likely get a
               full chunk of data with every read.  If a record is larger than
               the record size you've set, you'll get the record back in
               pieces.

               On VMS, record reads are done with the equivalent of "sysread",
               so it's best not to mix record and non-record reads on the same
               file.  (This is unlikely to be a problem, because any file
               you'd want to read in record mode is probably unusable in line
               mode.)  Non-VMS systems do normal I/O, so it's safe to mix
               record and non-record reads of a file.

               See also "Newlines" in perlport.  Also see $..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum