Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello anita2R,

If you follow BrowserUk’s advice (as you should) then it may help you to know where your original post ended. Here’s my best reconstruction of the final subroutine:

# # ******* Sequential 2-line Messages ******* # sub seqdis { my $seqdisParam = $_[0]; =head2 Sequential 2-line Messages =over 4 =item #* Split a long text into 2-line segments which are #* displayed sequentially. Text is split at spaces #* between words. optionally screen is cleared after #* last segment #* Options: #* 1. Display character every n milliseconds #* 2. display segment for n seconds #* 3. display final segment for n seconds 0=don't clear display #* 4. text to display #* Example: #* --seq-display '250,3,5,2,A long message that runs to many lines' #* Display characters every 250 milliseconds #* displaying the 2-line segments for 3 seconds, #* with the final part displayed for 5 seconds. #* the messages are repeated 5 times and the screen is cleared =back =cut # parse seqdis options my ($pulse, $sPause, $rPause, $rpt, $message ) = split( /,/, $seqd +isParam ); # # replace mapped characters and escape sequences $message = &replaceCc( $message ); my @mDisplay; my ($dataA, $dataB, $data1, $data2); # split message into display-width segments split at word boundari +es while ( length($message) > 0 ) { if( length($message) > $dWidth ) { # need to split message # get substring as long as display width # +1 to get word that ends at display width $dataA = substr( $message, 0, $dWidth +1 ); # cut at last space so as not to split a word ($data1) = split /\s+(?=\S*+$)/, $dataA; # remainder of string $message = s

BTW, it’s no longer considered good practice to call a subroutine using an ampersand prefix, which has the effect of circumventing prototypes. Unless you have a good reason to do this (and you usually won’t), omit the prefix:

$message = replaceCc( $message );

From perlsub:

A subroutine may be called using an explicit & prefix. The & is optional in modern Perl, as are parentheses if the subroutine has been predeclared. The & is not optional when just naming the subroutine, such as when it's used as an argument to defined() or undef(). Nor is it optional when you want to do an indirect subroutine call with a subroutine name or reference using the &$subref() or &{$subref}() constructs, although the $subref->() notation solves that problem.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re^3: Not too cool by Athanasius
in thread Not too cool by anita2R

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, 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
  • 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.
  • 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 exploiting the Monastery: (4)
    As of 2021-01-28 02:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?