develooper Front page | perl.perl6.language | Postings from February 2004

Exegesis 7: Thousands Separators

Thread Next
February 28, 2004 06:15
Exegesis 7: Thousands Separators
Message ID:
Praise to Damian for Exegesis 7: the new formats sound very
well-thought-out, flexible, easy-to-use, and extensive -- as well as
being implemented and available right now.  I've never used formats in
Perl 5, but I could see myself using Perl6::Form.

I have a few questions.  Unfortunately I'm only running Perl 5.6.1 here
so can't easily try out Perl6::Form and try to work out the answers from
that.  I've split them into separate mails so that they can have
distinct subjects, in the hope that'll be easier for people (and Piers
in particular).  This one's about thousands separators.

Pretty much any character can be used as a decimal point or as a
thousands separator.  All the examples show using either just a decimal
point or using both of them; having just a thousands separator is not
demonstrated.  Is that possible?  For example taking this data:

  @num = (72, 25783, 1000);

and wanting to produce:


Perhaps this works:

  print form '{>>,>>>}', @num;

But it's very similar to this:

  print form '{>>,<<<}', @num;

which treats the comma as a decimal point and therefore would yield:


Is the justification of the digits after the comma enough to be
unambiguous about what is meant?  And even if it is, is it sufficiently
unconfusing for humans having to use it?  Accidentally writing one of
the above when meaning the other one could be easy to do and hard to

Along similar lines, is it possible to have thousands separators after
the decimal point?  For example to get output like this:

  0.045 323
  0.032 200
  0.103 382

Would this format work?

  print form '{>.<<< <<0}', @small_num;

If not, could it be done some other way?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About