ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
This subroutine gets a string and logs it into a debug file. This file is for the user to see the progress/errors of using my tool.my $DEBUG_FILE = "log"; # Global sub debug { my ($t) = @_; return 0 unless(defined($DEBUG_FILE)); open my $fh, ">>",$DEBUG_FILE or return 0; my $prefix = "[".get_date()."][".basename($0)."](".$$."):"; print $fh $prefix.$t."\n"; close ($fh); return 1; }
Then it will update it to be:[07/10/21 17:56:57][run.pl](211653):<some info example1> [07/10/21 17:57:57][run.pl](211653):<some info example2> [07/10/21 17:58:57][run.pl](211653):<some info example3> [07/10/21 17:59:57][run.pl](211653):Running operation <operation>. Pro +gress: 57%.
Note that it won't add a new line, it will update the old line.[07/10/21 17:56:57][run.pl](211653):<some info example1> [07/10/21 17:57:57][run.pl](211653):<some info example2> [07/10/21 17:58:57][run.pl](211653):<some info example3> [07/10/21 18:05:57][run.pl](211653):Running operation <operation>. Pro +gress: 58%.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Recommended way to display progress
by kcott (Archbishop) on Jul 11, 2021 at 01:19 UTC | |
Re: Recommended way to display progress
by LanX (Saint) on Jul 10, 2021 at 22:58 UTC | |
Re: Recommended way to display progress
by AnomalousMonk (Archbishop) on Jul 11, 2021 at 00:14 UTC | |
Re: Recommended way to display progress
by Fletch (Bishop) on Jul 11, 2021 at 01:24 UTC | |
Re: Recommended way to display progress
by Marshall (Canon) on Jul 12, 2021 at 21:14 UTC |