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

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

by bdimych (Monk)
on Nov 30, 2007 at 14:01 UTC ( #654108=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $x = "";
    $x=~s/(.{0,3})/"'$1".(' 'x(3-length($1)))."'\n"/eg;
    ...
    '789'
    '0  '
    '   '
    
  2. or download this
    my $x = "";
    $x=~s/(.{1,3})/"'$1".(' 'x(3-length($1)))."'\n"/eg;
    ...
    '456'
    '789'
    '0  '
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2023-12-02 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (13 votes). Check out past polls.

    Notices?