imperl has asked for the wisdom of the Perl Monks concerning the following question:

Hi In the code, given below, the digits are separated using the colon, defined before the for loop. Now, if within the loop, I want to separate another set of numbers with a dot (period), how can I do it, since I can either define it as $"=':' or $"='.' Thanks
$" = ':'; for (my $int = 1; $int <= 999999999999; $int++) { my $leading = sprintf("%012d", $int); my @split = ($leading =~ /../g); print "@split\n"; }

Replies are listed 'Best First'.
Re: How to separate digits
by reasonablekeith (Deacon) on May 24, 2005 at 09:17 UTC
    I'm not 100% sure what you're after either. Does this help?
    for (my $int = 1; $int <= 999999999999; $int++) { my $leading = sprintf("%012d", $int); my @split = ($leading =~ /../g); print join(':', @split) . "\n"; print join('.', @split) . "\n"; }
    ---
    my name's not Keith, and I'm not reasonable.
      Thanks That helped :)
Re: How to separate digits
by prasadbabu (Prior) on May 24, 2005 at 09:16 UTC

    If i understood your question correctly,this might help you.

    @split = split/\./, $leading;

    Prasad

Re: How to separate digits
by blazar (Canon) on May 24, 2005 at 10:29 UTC
    I want to separate another set of numbers with a dot (period), how can I do it, since I can either define it as $"=':' or $"='.'
    <OT>
    Well, not strictly, since due to the way $" is actually used, with some trickery you can tie it to some suitable class. One such example I could find on PM is Re: Surprised by join, but I'm quite sure it has come out in other occasions as well.
    </OT>