Hi John,
Thank you for your comments.
Though I've been coding for many years I've never had a chance to
work in a team environment and thus never had the benefit of code reviews.
It's an education to see things from another viewpoint.
On Sat, Oct 30, 2010 at 03:16:51PM -0700, John W. Krahn wrote:
> Mike McClain wrote:
<snip>
> >use warnings; # duplicates -w
>
> It does not duplicate -w, in fact -w has no effect after this point in
> your program. See:
> perldoc perllexwarn
Since the first sentence in `perldoc perllexwarn` is:
'The "use warnings" pragma is a replacement for both the command line
flag -w and the equivalent Perl variable, $^W.'
You are technically correct but IMHO nitpicking. :;)
> >use integer;
> >$|++; # unbuffered STDOUT
>
> STDOUT still buffered but now autoflushed.
Point taken thank you.
> >$hi_ascii = 1 if( @ARGV&& ($ARGV[0] =~ /h/i) );
> Because the match operator returns true or false in scalar context you
> could write that as:
> my $hi_ascii = @ARGV && $ARGV[0] =~ /h/i;
Thank you, hadn't seen that.
> (And shouldn't that be 'a' for ASCII and 'h' for hexadecimal?)
No ascii is the default and 'h' for high ascii (128..255)
makes 'x' a logical choice for hex.
> > sp del/;
> ^^^^
> Since when is the space character a control character?
Never said it was but since space is used all over in the
table for readability 'sp' makes it clearer to me.
> >sub print_ascii
> >{ my ($mode, $hi) = @_;
> > else
> > { printf( "$sep$mode %s ", $i, chr($i) ); }
> ^^^^
> > { printf( "|$mode %s ", $i, chr($i) );
> ^
> One of these printf format strings is not like the other.
Oops, I'm fallible. :)
> And why are $sep and @symbols in file scope when they are only used
> inside this subroutine?
Because I'm often a bottom up programmer and often stop when it works.
Obviously they should have been inside but the sub came late in the process.
> And why is this subroutine *only* used for its side effect instead of
> having it return a value?
What you call side effect is to me primary effect.
I could have used sprintf and returned a string but don't see any advantage.
> John
Mike
--
Satisfied user of Linux since 1997.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/