Got it!

$string =~ s/(\S{40}/\1 /g;

does exactly the trick I need.

now I wonder if it is possible to print the resulting spaced string without
changing $string itself? do I really need a temporary variable or is it
possible to do something like:

print $string  s/(\S{40}/\1 /g;


"Jp" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am trying to split up a given string of unknown length with spaces at a
> given interval.
>
> eg.:
>
> $length=4;
>
$string="MIICWwIBAAKBgQDGz8+vl9M4z0a0f/slusZ+mkBO7c9QuiV7yNAlBPiXZv8E/6yX";
>
> should become:
>
> $new_string="MIIC WwIB AAKB gQDG z8+v l9M4 z0a0 f/sl usZ+ mkBO 7c9Q uiV7
> yNAl BPiX Zv8E /6yX"
>
> in  this example I used 4 character groups, in reality it will be 40
> characters or so.
>
> Any usefull hints are welcome.
>
> JP
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to