CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
working with pipes in perl

 



frosty
New User

Jun 28, 2007, 10:38 AM

Post #1 of 7 (643 views)
working with pipes in perl Can't Post

Hello!

I use perl for half of year yet. And need help with pipes.
I have application what render 3d graphics images and every frame it put number of frame to shell.
like this
1
2
3
4
...

I want to add percent and estimation time after each frame.
I try qx().
like this
1
2
3
4
5 - 10%
...

Question: How I can get every string (like1,2,3,4...) from my application and how I can replace existing strings?

Thank you!

Alex


(This post was edited by frosty on Jun 28, 2007, 10:42 AM)


KevinR
Veteran


Jun 28, 2007, 10:43 AM

Post #2 of 7 (640 views)
Re: [frosty] working with pipes in perl [In reply to] Can't Post

sorry frosty,

I simply do not understand what you are asking or what it is you are trying to do. Your subject mentions working with pipes, but your question has no information about what you are doing with pipes, and no code to look at.
-------------------------------------------------


frosty
New User

Jun 28, 2007, 11:32 AM

Post #3 of 7 (638 views)
Re: [KevinR] working with pipes in perl [In reply to] Can't Post

I am sorry. I try to describe it better. :)

My application put to shell strings with number of frames (1 string every 1-2 minutes)
example 1:
1
2
3
4
5
...

Sometimes number of frames more then 1000 :) And I need percents of completition instead simple numbers only.
Another words, I need get my numbers from example 1 and replace numbers on percents. And application works at this time. :)
output instead numbers should be like this
Total number of frames - 20 (100%)
1
2 (10%)
3
4 (20%)
5
6 (30%)
7
8 (40%)
9
10 (50%)
11
12 (60%)
13
14 (70%)
15
16 (80%)
17
18 (90%)
19
20 (100%)

I know how I can get full output after apllication finished job
qx(myApplication -option1 -optionN);

But I need get and replace every string at the moment of appearing it in the shell.

Hope I describe my problem better then in the last time. :)


(This post was edited by frosty on Jun 28, 2007, 11:35 AM)


KevinR
Veteran


Jun 28, 2007, 11:58 AM

Post #4 of 7 (635 views)
Re: [frosty] working with pipes in perl [In reply to] Can't Post

You can only get the percent finished if you know before how many total frames there will be when the script/application starts running.
-------------------------------------------------


frosty
New User

Jun 28, 2007, 12:48 PM

Post #5 of 7 (633 views)
Re: [KevinR] working with pipes in perl [In reply to] Can't Post

I know how many frames I have. I need intermidiate percents in the process.


KevinR
Veteran


Jun 28, 2007, 1:50 PM

Post #6 of 7 (631 views)
Re: [frosty] working with pipes in perl [In reply to] Can't Post

OK, then don't use qx(), use open() and a pipe to the application and read each line as the application ouputs it to perl and based on the value of the line you can determine the calculation for the percentage finished. See if this link helps you with the pipe open:

http://perldoc.perl.org/perlopentut.html

Figuring the percentage stuff should be very easy once you know how to read the output of the application line by line.
-------------------------------------------------


frosty
New User

Jun 28, 2007, 2:31 PM

Post #7 of 7 (630 views)
Re: [KevinR] working with pipes in perl [In reply to] Can't Post

Thank you very much! :)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives