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

How do I split the 3 digits for the $SPSS_figures variable into 3 variables (one for each digit)
if ($line =~ /^(\d{1,6})\t(\d{3})/){ my $count = $1; my $SPSS_figures = $2; }

Replies are listed 'Best First'.
Re: how to split a 3 digit string?
by gjb (Vicar) on Dec 01, 2002 at 18:10 UTC

    my @digits = split(//, $SPSS_figures); should do the trick.

    Hope this helps, -gjb-

Re: split
by pg (Canon) on Dec 01, 2002 at 18:25 UTC
    This should also do it:
    /^(\d{1,6})\t((\d)(\d)(\d))/
    $2 holds the entire SPSS_figures, while $3, $4, $5 hold each digit.
Re: how to split a 3 digit string?
by bronto (Priest) on Dec 05, 2002 at 16:35 UTC
    @digits = ($SPSS_figures =~ /\d/g )

    Ciao!
    --bronto

    # Another Perl edition of a song:
    # The End, by The Beatles
    END {
      $you->take($love) eq $you->make($love) ;
    }