in reply to Printing to stdout an array of strings and scalar references
I am not sure if this fits into what you're trying to do, but why not simplify the matter by building the output where and when you need it:
Or even simplify further the notify_progress subroutine:$ perl -e '#!/usr/bin/perl > use warnings; > use strict; > > my $count = 42; > my $completed = 6; > > notify_progress(); > $completed = 7; > notify_progress(); > > sub notify_progress { > my $progress_output = ["\rProcessing: ", $count, " files to proc +ess ; ", $completed, " files completed\n"]; > print @$progress_output; > }' Processing: 42 files to process ; 6 files completed Processing: 42 files to process ; 7 files completed
And, BTW, do yourself and other monks a favor, take the time to register an account. ;-)$ perl -e '#!/usr/bin/perl > use warnings; > use strict; > > my $count = 42; > my $completed = 6; > > notify_progress(); > $completed = 7; > notify_progress(); > > sub notify_progress { > print "Processing: ", $count, " files to process ; ", $complete +d, " files completed\n"; > }' Processing: 42 files to process ; 6 files completed Processing: 42 files to process ; 7 files completed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing to stdout an array of strings and scalar references
by Anonymous Monk on Oct 25, 2017 at 02:36 UTC | |
by Laurent_R (Canon) on Oct 25, 2017 at 07:45 UTC |