CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: Counting Characters at at time.: Edit Log


Aug 5, 2005, 12:26 PM

Views: 7504
Counting Characters at at time.

Is there a way to count characters at a time? I am trying to count 200 characters for each string, and then split those groups into a array. I know it's possible, but wanted to first check if I should try to do a loop to count, then a split once I reached say my 200th character. I'm a perl newbie, of course!

I have the following:

$file = 'data.txt' ; # Name the file
open(INFO, "<$file") ; # Open the file
close(INFO) ; # Close the file

$str = <INFO>;
@snippet @snippet = split (/ /, $str); # split into an array of size 200 characters each

I guess the split commands splits at white space. Is there an easy way to manipulate the function to split at some nth character, say 200 characters?

Thanks bunches! I look forward to contributing myself wherever possible.

(This post was edited by upyeronson on Aug 5, 2005, 12:27 PM)

Edit Log:
Post edited by upyeronson (Novice) on Aug 5, 2005, 12:27 PM
Post edited by upyeronson (Novice) on Aug 5, 2005, 12:27 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives