Closed Thread Icon

Preserved Topic: Perl Advances STDOUT (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21087" title="Pages that link to Preserved Topic: Perl Advances STDOUT (Page 1 of 1)" rel="nofollow" >Preserved Topic: Perl Advances STDOUT <span class="small">(Page 1 of 1)</span>\

 
WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-09-2002 09:19

I am not even sure if this is possibe, but I thought it might be worth a try.

I am working on a perl script (will be shared upon completion), and I want to be able to show the percentage of the process that is complete.

It can easily be done by simply printing the percentage completed. However, this can easily get unweildy as you would have possibly hundreds of different print statements scrolling down you screen.

I have however used programs (most likely written in C / C++) which overwrite a given block out output. So that as in a progress counter the numbers remain in the same place, never moving your screen.

I am not even sure what to call this, so it makes searching near impossible for me.

Possible or impossible with perl, if you have any thoughts or ideas I would love to hear them.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-09-2002 12:09

Screen manipulating (text mode) is usally done by using Unix curses library... Also, there are other modules which you can use, and I'll list them here:

  • Win32::Console, if your script is going to run under Windows platform, this module is perfect
  • Various curses modules, you can do a lot of different things with curses library
  • Various terminal handling modules, if you don't need fancy stuff that curses library provides, you can use simpler modules, like Term::ANSIScreen, which can also do the job




WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-09-2002 17:35

Max, thanks for the links. I think that Term::ANSIScreen is going to be the method I will use. Thanks a lot, I wasn't sure that any of this was even possible.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-10-2002 00:04

Everything is possible, heh...


WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-10-2002 02:39

Max,

have you run Win32::Console?

I seem to have some trouble working the input correctly.

I have defined two Win32::Console object, $STDIN and $STDOUT guess what they do

If I want to input some string say to get a directory path:

$rootdir = $STDIN->InputChar(x);

Where x would be the size of the input.

Now here is where it gets tricky. My input could be from say 3 characters C:\ to hundreds of characters.

Say I set x to be 999 then $rootdir contains no information.

But if I set x to be equal to the length of the input the correct result is obtained. If I set x to be +1 or +2 the length of the input, it is still fine. However anything >+2 the input size grabs no visible information. Less than the length returns the appropriate number of characters in the input.

It seems that I must be going about something really wrong here, because user input is variable and I am sure that the programmer(s) that worked on this would not have thought of that.

Do you know anything about this?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-10-2002 09:39

I have just tried using InputChar function like in you example, and got the same error. I guess that something is fucked up with _ReadConsole function from console C library (console.cpp source file), which this perl module calls. Maybe that is the desired effect ? who knows what Microsoft thinks, eh?

Anyway, one way to solve this is to input one character at a time, until return character is pressed (key code 13).

Or you can simply use the traditional way:

$rootdir = <STDIN>;


WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-10-2002 18:15

Yes, but the <STDIN> wouldn't read from the newly created console.

That one character at a time seems like a good idea. Let me see if I can come up with any ideas on this one.

Gonna check with the mailing list, maybe they have a solution.

« BackwardsOnwards »

Show Forum Drop Down Menu