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

Re: [PBML] Nother Quick Question

Expand Messages
  • Dustin Smith AKA GIDustin
    Thank you to all who replied. Worked like a charm GIDustin ... -- My Home Page: http://www.gidustin.net Alternate: http://www.civ3files.com -- When NASA
    Message 1 of 5 , Sep 1, 2003
    • 0 Attachment
      Thank you to all who replied. Worked like a charm

      GIDustin



      Quoting Damien Carbery <daymobrew@...>:

      > --- In perl-beginner@yahoogroups.com, Paul Archer <tigger@i...> wrote:
      > > 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
      >
      > And if you retain the delimiters with:
      > @squares=split(/(..)/, $line); # Note brackets.
      > you will get:
      > 'AA', '', 'BB', '', 'CC', etc
      > i.e. the delimiters (AA, BB etc) are retained along with the items
      > between them (which are all zero length).
      >
      >
      >
      >
      >
      > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
      >


      --
      My Home Page: http://www.gidustin.net
      Alternate: http://www.civ3files.com
      --
      When NASA first started sending up astronauts, they quickly discovered that
      ballpoint pens would not work in zero gravity. To combat the problem, NASA
      scientists spent a decade and 12 Billion Dollars to develop a pen that writes
      in zero gravity, upside down, underwater, on almost any surface including
      glass
      and at temperatures ranging from below freezing to 300C.

      The Russians just used a pencil.
      --
      The 10 Commandments consist of 279 words.
      The Declaration of Independence is 300 words long.
      The EU Ordinance on the Import of Caramel Sweets consists of 25911 words...
    Your message has been successfully submitted and would be delivered to recipients shortly.