Morning Monks

This isn't really a detailed technical question, it's more a "accepted norm" query. As I have thought myself Perl without any immediate "go-to" person (there is nobody in my work environment that knows anything about coding!) I find I that I am struggling with coding practices and principles a lot.

I have recently moved from small (under 1000 lines) scripts to larger, modular, OOP projects. I won't lie, I am finding the concept a little difficult, especially coming from a non-coding background! Anyway, my question involves the creation of an instance and specifically how acceptable it is to modify it. Example:

Suppose this simple code:
#!/usr/bin/perl use strict; use warnings; use Storm; use Data::Dumper; my $config = { storm_server => '172.16.0.55', storm_port => '9001', storm_auth_login => '0', storm_login => '1', storm_user => 'stormuser', storm_pass => 'pass', }; my $self = Storm->new($config); print Dumper $self; package Storm; use IO::Socket; sub new { my $class = shift; my $self = shift; # The next lines, should this be here or in another # method if( $self->{storm_auth_login} ) { $self->{append_text} = "X12-" } bless $self, $class; return $self; }
As you can see I am creating an instance with a $config hash ref with certain information. However, is it the "norm / acceptable", as above, to check the argument and based on a value then modify it.
OR, is it better/normal to create a "blank" instance and then pass that into another method to change/modify?
OR, the third option: I am getting way to bogged down on what is the "norm" and I should worry more about my apparent lack of understanding of how OOP works!

In reply to High level OOP query by packetstormer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.