Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Basic DNS Record Creation

by merlyn (Sage)
on Feb 06, 2001 at 11:33 UTC ( #56632=note: print w/replies, xml ) Need Help??


in reply to Basic DNS Record Creation

Having selected the link of "Comment on...", I feel obliged to comment on this program after a cursory glance as follows.

I find your introduction of the synthetic variable $control to be very confusing to follow. I had to read that loop three times to figure out when you were getting out to verify that it was doing what the text said it was doing. I think you want this general idiom:

{ print "value for XYZ? "; chomp($xyz = <STDIN>); unless (validate $xyz) { print "$xyz is not a valid XYZ\n"; redo; } print "confirm value $xyz for XYZ? (y/n)"; redo unless <STDIN> =~ /^y/i; }
In fact, you can bundle this up as a subroutine, and it'd make even more sense. If you ever find yourself typing the same code two or three times, except for some parameters (used in its most generic sense here), it's a good candidate for factoring out. I heard somewhere once "put the regular part as code, and the irregular part as data". And that really makes sense.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Basic DNS Record Creation
by CiceroLove (Monk) on Feb 06, 2001 at 21:49 UTC
    I agree on all points whole heartedly. I am just now getting into OOPing stuff. And I find my biggest problem is that I don't have a good grasp of things like redo and validate and the like. Which makes it difficutl for me to always see _how_ I can make something "uniquely generic" so to speak. Thanks very much for the advice and the new terms. CiceroLove

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2021-08-06 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (44 votes). Check out past polls.

    Notices?