#!/usr/bin/perl -w

use strict;

my @dewey = qw(123.456 123 456 456.123);

foreach my $dewey (@dewey) {
  my($pre, $post) = split(/\./, $dewey);

  # Iterate over each character in pre
  my @chars = split(/ */, $pre);
  for(my $i = 0; $i <= $#chars; $i++) {
    print $chars[$i];
  }

  # If post is defined, iterate over each character in that too.  Print
  # a dot to separate them
  if(defined $post) {
    print ".";
    @chars = split(/ */, $post);
    for(my $i = 0; $i <= $#chars; $i++) {
      print $chars[$i];
    }
  }

  print "\n";
}

# This is equivelent to "print join("\n", @dewey);"
