Here's a first draft, incomplete implementation a possible response to my notion (YMMV) that Perl's CLI debugger is intimidating to novices (well, it was to me... for several years).
IOW, here's a simple-minded, do-nothing, little script that invites the user to explore some debugger commands in circumstances in which s/he need not fear will be tantamount to rm rf (or del *.* /s, if 'doze in the learner's OS flavor).
My hope is that the minimal set of operations in the script give a hint of (or maybe "are extensive enough for a start?") the range of debugger options/commands which the user would be well advised to learn.
The specific RFC follows the code:
#!/usr/bin/perl
use 5.014; # modify to match your "perl -v"
unless (@ARGV) {
say "debugger practice; on restart, 1st arg must be a number\n";
exit;
}
say "Explore debugger commands w expr W expr b Ln|Event B Ln|Event (et
+c incl l v s n)\n";
my ($var1, $var2, $var3);
my @arr = qw (a b c d e f g);
sub testable {
# useless uninformative comment
my $subvar1 = shift;
say "\t In sub testable, \$var1: $var1";
my $subvar2 = shift;
say "\t AS PASSED TO SUB, \$var2: $var2";
$subvar2 *= 5;
say "\t In sub testable, \$subvar2: $subvar2";
my $subvar_rand_int = int(rand($subvar2));
say "\t In sub, \$subvar_rand_int is: $subvar_rand_int.";
return $subvar_rand_int; # to $result
}
chomp($var1 = shift);
$var2 = int(3*$var1);
say "Pre_sub, \$var1: $var1 and \$var2: $var2";
push my @pass_to_sub,$var1;
push @pass_to_sub,$var2;
my $result = testable(@pass_to_sub);
say "Back from sub with \$result: $result";
# another comment for exploration of the deugger
for $_(@arr) {
$_ .= "_foo";
say "$_ " x $result;
say "\n";
}
So, the question: are this notion and this approach worth pursuing, further, with additional scripts focusing on packages, OO, modules, etc... If so, where should that focus begin?
Or should one, IYO, focus instead on getting noobs to use some of the available (often for $$$) GUI debuggers/other debuggers?
-
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.