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

Re^2: Dhcpclient module

by drip (Beadle)
on Mar 31, 2008 at 01:50 UTC ( [id://677430]=note: print w/replies, xml ) Need Help??


in reply to Re: Dhcpclient module
in thread Dhcpclient module

i was not quite aware of the indentation.i was just writing the code and was trying to do it the way i can read it..(since it is not done yet, but it works though)..
i'll just have to change the the indentation later..thanks for your opinion ..i'll try applying your suggestions to the code..

btw, on the sub new i set
$self->{INTERFACE},$self->{MACADDRESS} etc. to get default
values if there are no arguments being passed ...that is why
i used $self->{MACADDRESS} $self->{INTERFACE} etc (incase the user does not pass any argument)..maybe i'm wrong..kindly check the sub new again please...

Replies are listed 'Best First'.
Re^3: Dhcpclient module
by tachyon-II (Chaplain) on Mar 31, 2008 at 10:05 UTC

    Indentation is not something to fix later. The whole idea is to make code more readable so you don't confuse yourself when you write it and people reading it don't get confused. I suggest you run it through perltidy. The fact that it works has nothing to do with indentation. See obfuscation for unreadable code that works just fine.

    With OO you write accessors and then use them EXCLUSIVELY. The accessors provide the INTERFACE. By doing this you are free to change whatever you want about your internal object representation - so long as the accessors work the same all will be well with any code using your code.

    Debug this:

    my $interface = $obj->interrface; $obj->{INTERRFACE} = $new_interface;
      yeah, the fact that it works has nothing to do with indentation
      what i meant on my previous post was, the scipt works(though, obviously i messed up some things) and i was not referring to indentation..

      sorry to be a pain in the ass...thank you very much for your advice
      i'll read more on acessors..it seems i missed some part of it..hmm..

        You seem to have missed the significance of the debugging example. In both cases there is a spelling error. In the first case perl will die with an error. In the second case it will silently create a new hash element with the wrong name. You will go over the code many times trying to see why $obj->{INTERFACE} is NULL.....

        Cheers

        tachyon

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found