Prev: FAQ 6.15 How can I print out a word-frequency or line-frequency summary?
Next: FAQ 4.63 Why don't my tied hashes make the defined/exists distinction?
From: sreservoir on 1 Apr 2010 19:39 On 3/31/2010 3:16 AM, Ben Morrow wrote: > > Quoth sreservoir<sreservoir(a)gmail.com>: >> >> this is, incidentally, slightly ridiculous. >> >> % perl -E'sub STDOUT::a { die "right blocking" } >> say((*{STDOUT}{PACKAGE})->blocking);' >> Can't locate object method "blocking" via package "main" at -e line 2. >> >> um. > > *STDOUT{PACKAGE} returns a string indicating which package *STDOUT is > in, in this case "main". And no, it doesn't get preferentially treated > as a package name, not even if you use *STDOUT::new{PACKAGE}. er, I misread the docs on that. can we just say that this part of perl is _weird_? -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe."
From: Justin C on 3 Apr 2010 14:58 In article <52ea87-2m51.ln1(a)osiris.mauzo.dyndns.org>, Ben Morrow wrote: > > Quoth Justin C <justin.1003(a)purestblue.com>: >> >> Well thanks a whole *huge* bunch, guys. Just when I start thinking I'm >> starting to understand what I'm doing you go and confuse the hell out of >> me! I spend a lot of my time in this group reading that I should refer >> to documentation, and then you go and contradict the damn documentation! > > I apologise (somewhat). I was being something of a smartass, which while > generally expected on Usenet is less than helpful to those trying to > learn the language. (The group isn't solely (or even mostly) for their > benefit, of course.) Thanks Ben, and Tad, for the follow-up on this. I'll re-read the Indirect Object Syntax from perlobj again later, I find that several read-throughs are necessary with some time to digest in between! Justin. -- Justin C, by the sea.
From: Uri Guttman on 3 Apr 2010 16:47 >>>>> "JC" == Justin C <justin.1004(a)purestblue.com> writes: JC> In article <52ea87-2m51.ln1(a)osiris.mauzo.dyndns.org>, Ben Morrow wrote: >> >> Quoth Justin C <justin.1003(a)purestblue.com>: >>> >>> Well thanks a whole *huge* bunch, guys. Just when I start thinking I'm >>> starting to understand what I'm doing you go and confuse the hell out of >>> me! I spend a lot of my time in this group reading that I should refer >>> to documentation, and then you go and contradict the damn documentation! >> >> I apologise (somewhat). I was being something of a smartass, which while >> generally expected on Usenet is less than helpful to those trying to >> learn the language. (The group isn't solely (or even mostly) for their >> benefit, of course.) JC> Thanks Ben, and Tad, for the follow-up on this. I'll re-read the JC> Indirect Object Syntax from perlobj again later, I find that several JC> read-throughs are necessary with some time to digest in between! there isn't much more to learn. just do Foo->new() and you will be fine in all normal cases with little to worry about. avoid new Foo() too. the fact that old docs show indirect calls is irrelevent, they haven't been encouraged to update them to direct method calls. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Philip Potter on 5 Apr 2010 07:24
On 03/04/2010 21:47, Uri Guttman wrote: >>>>>> "JC" == Justin C <justin.1004(a)purestblue.com> writes: > > JC> In article <52ea87-2m51.ln1(a)osiris.mauzo.dyndns.org>, Ben Morrow wrote: > >> > >> Quoth Justin C <justin.1003(a)purestblue.com>: > >>> > >>> Well thanks a whole *huge* bunch, guys. Just when I start thinking I'm > >>> starting to understand what I'm doing you go and confuse the hell out of > >>> me! I spend a lot of my time in this group reading that I should refer > >>> to documentation, and then you go and contradict the damn documentation! > >> > >> I apologise (somewhat). I was being something of a smartass, which while > >> generally expected on Usenet is less than helpful to those trying to > >> learn the language. (The group isn't solely (or even mostly) for their > >> benefit, of course.) > > JC> Thanks Ben, and Tad, for the follow-up on this. I'll re-read the > JC> Indirect Object Syntax from perlobj again later, I find that several > JC> read-throughs are necessary with some time to digest in between! > > there isn't much more to learn. just do Foo->new() and you will be fine > in all normal cases with little to worry about. avoid new Foo() too. the > fact that old docs show indirect calls is irrelevent, they haven't been > encouraged to update them to direct method calls. Agreed. And if you want to enforce direct object syntax, you can use indirect.pm from CPAN like this: no indirect ':fatal'; (This isn't necessarily a good idea, particularly if you're working with existing code; but I feel the arguments for its use are similar to 'use strict') Phil |