Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Splitting a long string

by GrandFather (Saint)
on Aug 22, 2007 at 08:51 UTC ( [id://634275]=note: print w/replies, xml ) Need Help??


in reply to Splitting a long string

For a modest size string like that:

for my $temp ($str =~ /.{1,1000}/g) { # do stuff with $temp }

is probably sufficiently fast.

Update: s/1000/1,1000/ per almut's catch.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Splitting a long string
by almut (Canon) on Aug 22, 2007 at 09:59 UTC

    Minor nitpick: to get the last block of 400 chars as well, that regex should be /.{1,1000}/g, i.e. min 1, max 1000.

Re^2: Splitting a long string
by uvnew (Acolyte) on Aug 22, 2007 at 11:15 UTC
    Yep, that's perfect. Thank you all!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://634275]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found