Strange problem with print

11 views
Skip to first unread message

gamo

unread,
May 22, 2021, 2:43:43 PMMay 22
to

I have a program like this:

#!/usr/bin/perl -w

$|=1;

while (1){
blah();
if ($success){
localsearch();
report(); # this is OK
}
}

exit 1;

sub report {
system "clear";
print "this $value \n";
print FILE "this $value \n";
return;
}

sub localsearch {
doimprove();
report(); # this is not OK, doesn't seems to work
return;
}

Do you have an explanation to that bahavior?
Thanks!



--
http://gamo.sdf-eu.org/
perl -E 'say "Want a reverse joke? Yes? Begin to laugh.";'

Ben Bacarisse

unread,
May 22, 2021, 4:59:15 PMMay 22
to
gamo <ga...@telecable.es> writes:

> I have a program like this:
>
> #!/usr/bin/perl -w
>
> $|=1;
>
> while (1){
> blah();
> if ($success){
> localsearch();
> report(); # this is OK
> }
> }
>
> exit 1;
>
> sub report {
> system "clear";
> print "this $value \n";
> print FILE "this $value \n";
> return;
> }
>
> sub localsearch {
> doimprove();
> report(); # this is not OK, doesn't seems to work
> return;
> }
>
> Do you have an explanation to that bahavior?

Something is wrong in a part of the program you are not showing us.

Post as short a complete example as you can and trt to say what you mean
by doesn't seem to work.

--
Ben.

gamo

unread,
May 22, 2021, 6:57:31 PMMay 22
to
El 22/5/21 a las 22:59, Ben Bacarisse escribió:
Sorry Ben, but I think I wrote the basic structure and the result is
that the screen does not blink at the spected rate.

--
http://gamo.sdf-eu.org/
perl -E 'say "User error. Insert another user.";'

$Bill

unread,
May 22, 2021, 7:43:35 PMMay 22
to
On 05/22/2021 15:57, gamo wrote:
>
> Sorry Ben, but I think I wrote the basic structure and the result is
> that the screen does not blink at the spected rate.

If he can't run it (insufficient code provided), how do you expect him to
debug it for you?

You need to provide the smallest running and failing example possible.
In the process of creating that, you'll probably fix it yourself. ;)



gamo

unread,
May 22, 2021, 8:10:00 PMMay 22
to
El 23/5/21 a las 1:43, $Bill escribió:
Thanks, Bill, that's a good idea, but I could go the other way around
trying to find a replacement to

system "clear";

which I think is the weak point of the chain, and see what happens.

;)

--
http://gamo.sdf-eu.org/
perl -E 'say "Error: The temperature entered is below absolute zero.";'

Ben Bacarisse

unread,
May 22, 2021, 9:16:46 PMMay 22
to
gamo <ga...@telecable.es> writes:

> El 23/5/21 a las 1:43, $Bill escribió:
>> On 05/22/2021 15:57, gamo wrote:
>>>
>>> Sorry Ben, but I think I wrote the basic structure and the result is
>>> that the screen does not blink at the spected rate.
>>
>> If he can't run it (insufficient code provided), how do you expect him to
>> debug it for you?
>>
>> You need to provide the smallest running and failing example possible.
>> In the process of creating that, you'll probably fix it yourself.  ;)
>
> Thanks, Bill, that's a good idea, but I could go the other way around
> trying to find a replacement to
>
> system "clear";
>
> which I think is the weak point of the chain, and see what happens.

You may be able to capture the control sequence that clear uses so you
don't have to run a command every time:

my $cls = `clear`;
...
print $cls, "this $value\n";

or you can use $cls = `tput clear` if you have the tput command.

But I imagine the problem is to do with the timing since you are
probably relying on a software emulation of a terminal.

--
Ben.

gamo

unread,
May 22, 2021, 9:35:55 PMMay 22
to
El 23/5/21 a las 3:16, Ben Bacarisse escribió:
>> Thanks, Bill, that's a good idea, but I could go the other way around
>> trying to find a replacement to
>>
>> system "clear";
>>
>> which I think is the weak point of the chain, and see what happens.
> You may be able to capture the control sequence that clear uses so you
> don't have to run a command every time:
>
> my $cls = `clear`;
> ...
> print $cls, "this $value\n";
>
> or you can use $cls = `tput clear` if you have the tput command.
>
> But I imagine the problem is to do with the timing since you are
> probably relying on a software emulation of a terminal.
>

I found a good alternative that does the job with no blink at all:

printf "\033c";

Thanks!

--
http://gamo.sdf-eu.org/
perl -E 'say "free + return give me the setence: FISH RAM";'
Reply all
Reply to author
Forward
0 new messages