Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How can I split a string into chunks of size n bytes?

by Masem (Monsignor)
on Apr 23, 2001 at 22:37 UTC ( [id://74818]=note: print w/replies, xml ) Need Help??


in reply to How can I split a string into chunks of size n bytes?

@bits = ( $scalar =~ /.{1,$bytes}/gs );

Edited by tye to add "s" on the end otherwise "." won't match newlines.

Edited by chipmunk to change {0,$bytes} to {1,$bytes}; otherwise a null string is matched at the end.

Log In?
Username:
Password:

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

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

    No recent polls found