Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Actually, I am fond of these simple tasks that can make our lives easier...

When I call this script I use to mention one or two arguments that would make additional effects to the text...

The following code, adds some formating to the text. By default, it writes columns of 60 characters. But it is possible to specify any number of columns.

my $cant; $cant =shift || 60 ; ## DEFAULT: 60 COLS. use Text::Format; my $anco; ## 1ST.LINE LEFT MARGIN $anco = length($1) if ($text=~/^( +)/);## MARGIN? $anco = 0 if ($anco < 1 or $anco >= $cant);## ERROR? $cant -= $anco; ## FORMAT WITHOUT LEFT MARGIN TO ADD my @tod = (split(/\n+ */,$text)); $text=new Text::Format({ columns => $cant, text => \@tod, justify => 1, firstIndent => 0}); $result.= join(" ", ($text->paragraphs())); if ($anco) ## FORMAT WITH 1ST. LINE MARGIN... { @tod= (split(/\n+ */,$result));## GET EVERY LINE my $cant= ' ' x $anco; ## LEFT MARGIN IN SPACES $result = $cant. join("\n$cant",@tod); ## ADD LEFT MARGIN AND OUTPUT } $CLIP->Set($result); ## TO THE CLIPBOARD...
I can also transform plain text into HTML code, extract certain phrases with REGEX, transform the text into a commented block, unescape characters or escape them, sort the lines, turn them all into upper/lowercase and even eval some code while leaving it's result as the output.

This is what I call a useful toolbox..


In reply to Re: Drop formatting to paste plain text from Clipboard by chanio
in thread Drop formatting to paste plain text from Clipboard by EdwardG

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (15)
    As of 2014-07-30 11:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (230 votes), past polls