Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-23 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found