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

In reply to So nice, its poetry by Olecram

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.