Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: a simple exercise in readability

by apotheon (Deacon)
on Jan 15, 2007 at 14:55 UTC ( [id://594752]=note: print w/replies, xml ) Need Help??


in reply to Re^3: a simple exercise in readability
in thread a simple exercise in readability

You appear to have missed the significance of the following in my version:

HELP_MESSAGE() and exit unless $ARGV[1]; foreach (@ARGV) { HELP_MESSAGE() and exit unless /^-?\d+$/ }

As I stated, I removed the error checking from the variable assignments et cetera. The reason I did so is for maintainability. If you didn't miss that, and find that my approach is deficient, please let me know how it fails to achieve roughly the same results in use.

edit: More explicitly, I've changed liverpole's

use File::Basename; # [unrelated code] my $iam = basename $0; # [unrelated code] # Command-line (my $x = shift) or die $syntax; (my $y = shift) or die $syntax; # Validity checking ($x =~ /^-?\d+$/) or die "$iam: value $x not an integer\n"; ($y =~ /^-?\d+$/) or die "$iam: value $y not an integer\n";

to . . .

HELP_MESSAGE() and exit unless $ARGV[1]; foreach (@ARGV) { HELP_MESSAGE() and exit unless /^-?\d+$/ } my $start = shift @ARGV; my $end = shift @ARGV;

edit: johngg pointed out the "unless" bug above, where unless @ARGV should read unless defined @ARGV instead.

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re^5: a simple exercise in readability
by johngg (Canon) on Jan 15, 2007 at 15:55 UTC
    Sorry, I did miss that. I shouldn't post after two nights of hardly any sleep :(

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

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

    No recent polls found