Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: (How) Do you document/test your private subroutines?

by harangzsolt33 (Chaplain)
on Nov 07, 2018 at 00:15 UTC ( [id://1225342]=note: print w/replies, xml ) Need Help??


in reply to (How) Do you document/test your private subroutines?

I describe each sub, and then put a few comments here and there. But when I need to use this sub somewhere in a program, I usually just include a condensed version.
################################################# Trim # # This function removes whitespace, newline # characters and other special characters # before and after STRING. Returns a new string. # # Usage: STRING = Trim(STRING) # sub Trim { my $T = $_[0]; defined $T or return ''; my $N = length($T); my $X = 0; # ptr to first non-whitespace my $Y = 0; # ptr to last non-whitespace while ($N--) { if (vec($T, $N, 8) > 32) { $X = $N; $Y or $Y = $N + 1; } } return substr($T, $X, $Y - $X); }

Condensed version:

sub Trim { my $T = $_[0]; defined $T or return ''; my $N = length($T); my $X = 0; my $Y = 0; while ($N--) { if (vec($T, $N, 8) > 32) { $X = $N; $Y or $Y = $N + 1; } } return substr($T, $X, $Y - $X); }

Replies are listed 'Best First'.
Re^2: (How) Do you document/test your private subroutines?
by stevieb (Canon) on Nov 07, 2018 at 00:33 UTC

    Thanks harangzsolt33, hang in there young Monk.

    Listen, observe, criticize, question and think about everything you see and read by those more experienced, all the while posting your thoughts and ideas. That's how we all begin and learn.

    Your process here, although valiant and commendable, introduces some obscurity relative to what I was asking, and the design of your post is more for a single developer, not a team or crew of developers/collaborators.

    Stay with it. Ask questions. Answer questions. Bang your head on your desk periodically. All real devs do these things :D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 19:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found