in reply to column counter and printf question

That regex doesn't match what you think it does. The . is special. Tip #6 from the Basic debugging checklist: YAPE::Regex::Explain:

---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- 0 '0' ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- 00000 '00000' ----------------------------------------------------------------------

You could use map to format certain elements of your array:

use warnings; use strict; my @cols = qw(3.456 8.903 1.223); @cols = map { sprintf '%8.1f', $_ } @cols; print "@cols\n"; __END__ 3.5 8.9 1.2
Show some input and desired output.

Replies are listed 'Best First'.
Re^2: column counter and printf question
by fasoli (Beadle) on Oct 28, 2015 at 12:38 UTC

    Hi toolic,

    Yes, I should have remembered that . is a special character :( I didn't remember as I was lucky enough to match what I wanted but that was accidental.

    Regarding your suggestion, I don't understand how using quote word would help...? I don't get how I would include all the elements of my array as they're thousands of angle degrees? This map function looks useful and I'll try it and post the results, if I can find how to use it with/without qw.

      qw(3.456 8.903 1.223) is there only to set an example of an array with three values, to then show you how to process the fields of that array. You don't need to use it in your case.