Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to split_and_pad string to n-th chars pieces with one regular expression?

by bdimych (Monk)
on Nov 30, 2007 at 15:00 UTC ( #654128=note: print w/replies, xml ) Need Help??


in reply to How to split_and_pad string to n-th chars pieces with one regular expression?

many thanks, it is solved,
If combine BrowserUk's and mwah's solutions, then it works fine
$x=~s/(.{1,3}|^$)\n?/sprintf"'%-3s'\n",$1/eg;
it works even on multiline strings
---
and even multiline with emptyline mixed together
$x=~s/(.{1,3}|^$)\n?/sprintf"'%-3s'\n",$1/meg;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://654128]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-01-20 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (226 votes). Check out past polls.

    Notices?