HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl: Formatting Output
Operating System - HP-UX
1825773
Members
2202
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2004 01:39 AM
09-20-2004 01:39 AM
Hello Everybody,
I need to direct the output from a perl subroutine to the screen, but it should not get appended to the previous output whereas it should overwrite the previous.
Simply stating is it possible to replicate the progress meter of sftp.Is there any built-in function or any thought to implement this in perl.
HP-UX 11.11 is my platform and I use puTTY client.
Thanks for your help.
Regards
Michael
I need to direct the output from a perl subroutine to the screen, but it should not get appended to the previous output whereas it should overwrite the previous.
Simply stating is it possible to replicate the progress meter of sftp.Is there any built-in function or any thought to implement this in perl.
HP-UX 11.11 is my platform and I use puTTY client.
Thanks for your help.
Regards
Michael
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2004 01:47 AM
09-20-2004 01:47 AM
Re: Perl: Formatting Output
If you are using X-windows can use PerlTK and it has tools for a progress meter.
If you in character mode only, then a typical way to do a progress meter is to display it on a single line starting at the 1st column. For each line displayed, include a "\r" instead of "\n" to force a carriage return (but not new-line). Now you can overwrite the line you are on and re-display the progress meter.
HTH
-- Rod Hills
If you in character mode only, then a typical way to do a progress meter is to display it on a single line starting at the 1st column. For each line displayed, include a "\r" instead of "\n" to force a carriage return (but not new-line). Now you can overwrite the line you are on and re-display the progress meter.
HTH
-- Rod Hills
There be dragons...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2004 02:38 AM
09-20-2004 02:38 AM
Solution
my ($edone, $etodo, $enorm) =
$ENV{TERM} eq "xterm" || $ENV{TERM} eq "vt320" ?
map { "\e[${_}m" } qw(0;33;42;1 44 0) :
("", "", "");
sub slide ($$$)
{
my ($i, $n, $x) = @_;
$opt_v or return;
if ($i < 0 || $n <= 0 || $x <= 0) { # Forced reset */
$prv = -1;
printf STDERR "\r";
$slide->(0, 100, 1);
return;
}
$i % $x and return;
my $pct = $i * 100 / $n;
$opt_v > 2 || $pct != $prv or return;
my $str;
$prv = $pct;
if ($opt_v > 1) {
$str = sprintf " %-9d%*d %%%*d ",
$i, $xpct - 10, $pct, $cols - $xpct - 4, $n;
}
else {
$str = sprintf "%*d %%%*s", $xpct, $pct, $cols - $xpct - 3, "";
}
$pct > 100 and $pct = 100;
my $a = ($cols - 1) * $pct / 100;
printf STDERR "\r%s%.*s%s%.*s%s\r",
$edone, $a, $str, $etodo, $cols - 1 - $a, substr ($str, $a), $enorm;
} # slide
my $last = 10000;
foreach my $i (1 .. $last) {
slide ($i, $last, 100);
}
Something like that?
Enjoy, Have FUN! H.Merijn
$ENV{TERM} eq "xterm" || $ENV{TERM} eq "vt320" ?
map { "\e[${_}m" } qw(0;33;42;1 44 0) :
("", "", "");
sub slide ($$$)
{
my ($i, $n, $x) = @_;
$opt_v or return;
if ($i < 0 || $n <= 0 || $x <= 0) { # Forced reset */
$prv = -1;
printf STDERR "\r";
$slide->(0, 100, 1);
return;
}
$i % $x and return;
my $pct = $i * 100 / $n;
$opt_v > 2 || $pct != $prv or return;
my $str;
$prv = $pct;
if ($opt_v > 1) {
$str = sprintf " %-9d%*d %%%*d ",
$i, $xpct - 10, $pct, $cols - $xpct - 4, $n;
}
else {
$str = sprintf "%*d %%%*s", $xpct, $pct, $cols - $xpct - 3, "";
}
$pct > 100 and $pct = 100;
my $a = ($cols - 1) * $pct / 100;
printf STDERR "\r%s%.*s%s%.*s%s\r",
$edone, $a, $str, $etodo, $cols - 1 - $a, substr ($str, $a), $enorm;
} # slide
my $last = 10000;
foreach my $i (1 .. $last) {
slide ($i, $last, 100);
}
Something like that?
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP