Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Not too cool

by Athanasius (Archbishop)
on Jun 17, 2016 at 13:42 UTC ( [id://1165976]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Not too cool
in thread Not too cool

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,

Replies are listed 'Best First'.
Re^4: Not too cool
by anita2R (Scribe) on Jun 17, 2016 at 14:10 UTC

    Athanasius

    Thanks. I have removed most of the POD documentation from within the code, leaving only brief help documentation.

    This brings the code down in size enough to post within the limit. I won't include the other files including the full POD help file unless someone asks for it.

    I will go back and change the subroutine calls, but it will take a while to test that all works well. I will repost in due course

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found