Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Dumb Mistakes

by demerphq (Chancellor)
on Oct 03, 2001 at 15:53 UTC ( [id://116415]=note: print w/replies, xml ) Need Help??


in reply to Dumb Mistakes

Well, i'm not so sure this is a dumb thing to do. For one it allows more flexibility than ||, because you can add the word 'defined' to the beginning which is often the best way to handle defaults. Consider
my $value=0; my $string1=$value || "No value assigned" my $string2=$value ? $value : "No value assigned" my $string3=defined $value ? $value : "No value assigned"
Only $string3 will have the correct value.

What did I do as a mistake in my early stages? I underutilized modifiers leading to hard to read code, I had a lot of $var->{key}->{key}->{key}->{key} kind of stuff. Using temporary variables cleaned that up as well as learning that the form $var->{key}{key} is legit.

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Replies are listed 'Best First'.
Re: Re: Dumb Mistakes
by mirod (Canon) on Oct 03, 2001 at 16:06 UTC
    learning that the form $var->{key}{key} is legit.

    It is legit, but I wonder how many monks use it. I personally like the -> and I always write $var->{foo}->{bar}. I find it aesthetically pleasant as well as a good reminder of the fact that $var->{foo} is a reference and not a hash.

    I guess I am not the only one, given the overwhelmingly negative reaction to the replacement of the arrow by a dot in Perl 6 (which was probably Larry's goal now that I think of it, just to drive the point that Perl 6 is different from Perl 5 and that nothing is sacred).

      I'd like to know the rationale behind the decision before completely rejecting the change (see #43 thanks tilly) but it does seem to be an odd thing to change. Also if I've heard correctly the concat operator will be a underbar? Now that just reminds me of the broken VB run on statement syntax, which IMO is a bad recommendation. If you see what I mean.

      :-) Yves
      --
      You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-19 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found