From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 27 July 2005 14:46 To: activeperl@listserv.ActiveState.com Subject: Requirement or Syntactic Sugar? ---INTERNET EMAIL NOTIFICATION--- This email originates from the Internet and therefore may not be from the apparent sender. Please check any attachments carefully before opening them as they may not be as they appear. If you have any doubts about the origin or content of the email please contact PC Support on x2288. --- Hi, wizards. I've a small question this time. Working with WMI code (Win32_whatnot), I see two different syntaxes and I'm wondering if the "fancy" one is a requirement or if it's just pretty formatting. Here they are. Both start from this point: $stuff = $self->WQL( -query => "SELECT * FROM Win32_whatnot", -single => 1 ); Then the first format is just: $thing = $stuff->member;
This is a subrouting call. Assuming that $stuff is a blessed reference, then this is effectively '$thing = ref($stuff)::member($stuff);' While the fancy one is: $thing = $stuff->{member}; This is a hash lookup, assuming that $stuff is a hash reference. Since both work in the code that's using them, I suspect that the curlies in the fancy example are not really necessary. Am I right in this? You may be right in this instance as I believe that it is common for Win32 objects to provide access to their attributes using either method. However, in general, the two are not interchangeable. I know this is a trivial question, but I'm trying to unify a bunch of different modules, would like to get them stylistically in line, and don't want to mess things up by removing the curlies if they're really needed. OTOH, should they be added to the module code that already works without them? As long as both methods work, then it is your call really. A consistent coding style is good, but then again, as they say, "if it ain't broke, don't fix it". You will have to decide which is more important. HTH Thanks! Deane ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs