in reply to Re^2: Printing to stdout an array of strings and scalar references
in thread Printing to stdout an array of strings and scalar references

You are welcome.

OK, now I understand why you're using an arrayref with references to the counters. Although I guess a simple array with references to the counters would also work.

An alternative approach would be to build dynamically the output subroutine depending on your input:

#!/usr/bin/perl use warnings; use strict; my $verbose = shift // 0; my $excluded = 2; my $count = 42; my $completed = 6; my $notify_progress = build_output_subroutine(); $notify_progress->(); $completed = 7; $notify_progress->(); sub build_output_subroutine { my @out; if ($verbose) { return sub { print "Processing: ", $count, " files to proces +s ; ", $excluded, " files excluded; ", $completed, " files completed\ +n" }; } else { return sub { print "Processing: ", $count, " files to process + ; ", $completed, " files completed\n" }; } }
But, in this context, this probably does not really make things really simpler.
  • Comment on Re^3: Printing to stdout an array of strings and scalar references
  • Download Code