(Marty Landman) wrote:
> Eric Schwartz <> wrote:
>
> > Check the documentation on Perl diagnostics with 'perldoc perldiag'
> > and read the entry your message refers to.
>
> Got it. You can see I'm new to OOPing and apparently owing to the Perl
> versions was able to get away with an incorrect way of doing things.
>
> I have been blessing into either the package string, or if the package
> had already been instantiated with a hash ref would use that. But by
> just changing the line of code to bless into the package name the hash
> ref is automagically associated. Guess that's part of the point,
> right?
I'm not sure I follow you here... blessing an object associates it
with a package. ref $obj will return that package. So if $obj has been
blessed into package Package, the code
my $newobj = bless {...}, ref $obj;
will also bless $newobj into package Package. There is no association
between $obj and $newobj beyond the fact they are both blessed into
the same package.
> > $Quiz (as a personal aside, I hate it when a line of code includes two
> > variables named identically except for case) is probably not what you
> > think it is.
>
> TMTOWTDI aside, I wonder how bad my variable naming style is. Although
> what I do privately is obviously my own business, I don't want to
> develop habits that are unfriendly to others, y'know?
>
> To me it makes more sense to have e.g.
>
> my ($quiz, @quiz, %quiz)
My 2d:
Temporary variables should be in a small enough scope that essentialy
it doesn't matter what they're called, as you can see all uses of the
variable at once; thus they should have short, concise names. I do
sometimes use $foo and @foo; though there are often better names, like
@quizzes and $curquiz.
Globals (in which class I include lexicals whose scope covers more
than one sub, as well as package globals) should be meaningfully
named, and clearly rather than concisely. They are as much a part of
the interface to a given section of code as its sub names are. I tend
to name globals with an initial cap, just to distinguish them.
The only time I would use two variables with the same name in
different cases is where I have a scalar naming a file and a FH open
on that file, e.g.
my $config = $ENV{MY_CONFIG} || "$ENV{HOME}/.myconfig";
open my $CONFIG, '<', $config or die 'horribly';
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t #
$J::u:

:t, $a::n:

::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.