A tiny program for a heavy duty... its a so
slick regexp, I couldnt miss to post it here for all to see!
Originally ideated for a post someone did, but at which I missed to answer. The point was on dividing a string on 100 characters until it was possible. Well everybody used SUBSTR, but it didn't satisfy me... regexp is the way!
Follows the
£337 version
#!usr/bin/perl
$initial = "qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwerty
+uiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcv
+bnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdf
+ghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm";
$_= $initial;
$vardivider= 33;
$initiallength= length($initial);
@varformposts= (/(.{$vardivider}|.+$)/g); #THIS IS IT!
print "\nLength: " . $initiallength ." - Division by $vardivider: " .
+int($initiallength/ $vardivider) . " - Mod: " . $initiallength % $var
+divider . "\n";
print join("*\n", @varformposts);
AAaauuuuuhhhh! One row for such a nasty splitting job! £337!
And now for the £173 version
#!usr/bin/perl
$initial = "qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwerty
+uiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcv
+bnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdf
+ghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm";
$_= $initial;
@varformposts= (/(.{33}|.+$)/g); #OH MY! All the job in one single reg
+exp!
print join("*\n", @varformposts);
Man I feel better now, knowing that such a beauty would not be left alone in my HD.
Cheers