Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Add space in long string

by johngg (Abbot)
on May 28, 2013 at 13:29 UTC ( #1035598=note: print w/replies, xml ) Need Help??


in reply to Add space in long string

Using substr as an alternative to regex substitution and also grouping in fours from the right-hand side in case that is a requirement.

$ perl -Mstrict -Mwarnings -E ' sub ins { my $str = shift; my $len = length $str; while ( ( $len -= 4 ) > 0 ) { substr $str, $len, 0, q{ }; } return $str; } say ins( $_ ) for qw{ 1 10 110 1101 10010 101100 1110101 10001011 110100010 };' 1 10 110 1101 1 0010 10 1100 111 0101 1000 1011 1 1010 0010 $

I hope this is useful.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035598]
help
Chatterbox?
[Corion]: If all else fails, Spreadsheet::XLSX should be "installable" by manually copying the files, provided that the prerequisites are met
[thezip]: It fails in the "formatted 2-digit numeric" tests
[thezip]: Okay Corion, that's what I wanted to hear. Thanks!
[Corion]: Oh, a test failure... Just force-install it then? --force and potentially --notest to skip the tests alltogether ?
[ambrus]: thezip: is Activestate Perl usable for your scenario instead?
[MidLifeXis]: Yeah, --notest is good, not sure I would do --force.
[thezip]: It fails 2/10 tests in that group. What are the ramifications if I force it? What should I look for for?
[thezip]: I've migrated from ActiveState to Strawberry. No going back...
[thezip]: I'll try the --notest arg first when I get back from meetings (after lunch).
[thezip]: Thanks guys for your comments! :-)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (16)
As of 2017-03-23 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (290 votes). Check out past polls.