in reply to Add space in long string
use warnings; use strict; my $bin = '1001100010100001'; print add_space($bin), "\n"; sub add_space { # Add space separator # Code adapted from perlfaq5: How can I output my numbers with com +mas added? local $_ = shift; 1 while s/^([01]+)([01]{4})/$1 $2/; return $_; } __END__ 1001 1000 1010 0001
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Add space in long string
by lddzjwwy (Novice) on May 28, 2013 at 12:26 UTC |