The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

OptArgs2::StatusLine - terminal status line

VERSION

v2.0.13 (2025-04-04)

SYNOPSIS

use OptArgs2::StatusLine '$status';
use Time::HiRes 'sleep'; # just for simulating work
$status = 'working ... ';
sleep .7;
foreach my $i ( 1 .. 10 ) {
$status .= " $i";
sleep .3;
}
# You can localize $status for temporary changes
{
local $status = "temporary info";
sleep .8;
}
# Right back where you started
sleep .7;
$status = "Done.\n";

DESCRIPTION

OptArgs2::StatusLine provides a simple terminal status line implementation, using the perltie mechanism. Simply assigning to a $scalar prints the string to the terminal. The terminal line will be overwritten by the next assignment unless it ends with a newline.

You can create a status $scalar at import time as shown in the SYNOPSIS, or you can tie your own variable manually, even in a HASH:

my $self = bless {}, 'My::Class';
tie $self->{status}, 'OptArgs2::StatusLine';
$self->{status} = 'my status line';

Status variables have a default prefix of "program-name: ". You can change that two ways:

  • Assign a scalar reference:

    $status = \'New Prefix: ';
    $status = 'fine'; # "New Prefix: fine"
  • Use an ASCII record separator (i.e. chr(30)) which you can import as RS() if you prefer:

    $status = 'Other: ' . RS . 'my status'; # "Other: my status"
    $status = 'something else'; # "Other: something else"

You can import multiple status variables in one statement:

use OptArgs2::StatusLine '$status', '$d_status';
untie $d_status unless $DEBUG;
$status = 'frobnicating';
$d_status = 'frobnicating in detail, maybe';

SEE ALSO

OptArgs2

SUPPORT & DEVELOPMENT

This distribution is managed via github:

This distribution follows the semantic versioning model:

Code is tidied up on Git commit using githook-perltidy:

AUTHOR

Mark Lawrence <nomad@null.net>

LICENSE

Copyright 2022 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.