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
In reply to Re: Printing to stdout an array of strings and scalar references
by Laurent_R
in thread Printing to stdout an array of strings and scalar references
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |