in reply to how to split input data ?

What have you tried? you could use split with a little mucking about, but it would be easier to use a regular expression.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: how to split input data ?
by davidrw (Prior) on Nov 09, 2006 at 02:11 UTC
    does the look-behind count as mucking around? ;) (as opposed to having to shift off the first blank element)
    perl -le 'print join ":", split /(?<=\d\d)(\d\d)/, "123456789"'
    oh, i guess that doesn't work for '123' ... back to a little more mucking:
    perl -le 'print join ":", grep {length} split /(\d\d)/, "123456789"'
Re^2: how to split input data ?
by bh_perl (Monk) on Nov 09, 2006 at 01:56 UTC
    Currently, I am dump all the input data into array, then split it for +each two variables. I think that is not a good method. Do you know the simple solution ?

      Show us your current code and we will comment on that. That way we have some idea of what you know already.


      DWIM is Perl's answer to Gödel