Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

PERL - Split by Character


  • Please log in to reply
2 replies to this topic

#1 Cosmet

Cosmet

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 58 posts

Posted 21 December 2006 - 11:51 AM

Is there a way to split by character in perl?

Say if I read a file and have only one line but I need to get 0-128 as one line, 129-256 as next, etc... Is there a way to do this?
  • 0

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 23 December 2006 - 07:56 AM

You will have to use the substr function to get all 128

@array_here;

for ($i=0; $i<length(string);$i++) 
{
    push(@array_here, substr(string,128*i,128);
}


Hope that helps.
  • 0

#3 falco85

falco85

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 105 posts

Posted 30 December 2006 - 11:03 AM

Is perl still being used??
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download