Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Six uses for curlies?

by whio (Beadle)
on Jan 13, 2006 at 10:52 UTC ( [id://522946]=note: print w/replies, xml ) Need Help??


in reply to Re: Six uses for curlies?
in thread Six uses for curlies?

There is a ${, it's just that you have to (use disambiguation!) access it as ${{}. Much like $}, Perl doesn't use it internally for anything, but it is a punctuation global variable so use strict 'vars'; doesn't trigger on it.

Replies are listed 'Best First'.
Re^3: Six uses for curlies?
by Scott7477 (Chaplain) on Jan 13, 2006 at 14:57 UTC
    This is an excellent thread for folks new to Perl like me. Perhaps moving this thread to the Tutorials section would be appropriate.
    I have been wondering about significant examples of operator overloading within Perl and this is a good one.
    Perhaps a reason for the need for operator overloading is due to the finite number of symbols on a standard keyboard?
    To me having an operator with six or seven different meanings could lend to confusion, but perhaps the burden of concocting different operators for each of the seven meanings is too great.
    I haven't finished reading Wall et al's "Programming Perl" so I don't know what the creator's philosophy is in this regard.

    Edited by planetscape - removed small tags

      Perhaps a reason for the need for operator overloading is due to the finite number of symbols on a standard keyboard?

      Not necessarily, when you consider that any arbitrary language construct can be represented with any arbitrary arrangement of symbols, for example:

      MY_NAMED_BLOCK: BlockBegin ### No curly braces were used, but then this is just ### pseudocode, not perl. For (0..10): print sys.accumulator; print sys.newline; EndFor BlockEnd

      If you wanted to, you could easily write a script to convert that into perl. Is it perl? No, but it can be translated unambiguously.

      When I was new to programming, I used to be much more impressed with the fancy symbols, and I thought there had to be some esoteric and mathematically precise rationale for every element of syntax. Perhaps (on some very deep epistemological level) there is. Another explanation, however, is that some things are just plain easier to type, and different people have different preferences, backgrounds, expectations and styles.

      This is an important consideration, because it will help you to be less intimidated about learning new things in perl (and even learning new languages); and less mystified by conventions that may seem confusing at first, but end up saving you a *lot* of time and hassle when you understand what they are good for.


      =oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV
      Are {} "operators"? I don't think of them as such.

      To me, most of the aforementioned uses are conceptually the same. Braces surround something and return its result. Syntactically there is some difference, eg if ${foo}_bar really acted like a block then the foo would be a bare word, but conceptually if you think of braces as a block which is strongly bound to whatever is to the left of the opening brace, I don't think you'll go far wrong.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-19 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found