From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!/usr/bin/env perl
use strict;
use lib 'lib';
use OptArgs2::StatusLine '$status', 'RS';
use Time::HiRes 'sleep';
$|++;
# Just a simple status line
$status = 'working ... ';
sleep .5;
my $i = 1;
foreach ( 0 .. 2 ) {
$status .= ' ' . $i++;
sleep .8;
$status .= "\n" if $_ % 2; # newlines hang around the terminal
}
# You can localize messages
{
local $status = 'this is temporary';
sleep 0.9;
# You can change the prefix using the Record Separator RS
$status = 'My Cool Prefix: ' . RS . 'still temporary';
sleep 0.9;
}
# And the original returns automatically
sleep 1.3;
# A new prefix
$status = 'example: ' . RS . "Sort of Done.\n";
sleep 0.9;
$status .= ' ....';
$status .= "Really done.\n";