Loading ...
Sorry, an error occurred while loading the content.

16380Re: [PBML] Nother Quick Question

Expand Messages
  • Paul Archer
    Sep 1, 2003
    • 0 Attachment
      3:45am, Jeff 'japhy' Pinyan wrote:

      > On Aug 31, Dustin Smith AKA GIDustin said:
      >
      > >I have a string, a large string, and I want to put it in an array 2 chars
      > >at a time, so "AABBGGHHSS...." would be transefered into like @Array=
      > >("AA","BB","GG",....) How would I do that?
      >
      > >@squares=split(/.{2}/, $line);
      >
      > split() is the wrong tool for the job. Use this instead:
      >
      > my @squares = $line =~ /.{2}/g;
      >

      To expand on this slightly, the *reason* that split is the wrong tool for
      the job is that the pattern you use with split is the delimiter, and the
      delimiter is removed from the string. So you're saying every two characters
      (much more simply written as just /../, BTW) are delimiters, so remove
      them--leaving you with zilch.

      Paul
    • Show all 5 messages in this topic