From geoff.crompton at strategicdata.com.au Wed Nov 1 22:07:45 2006 From: geoff.crompton at strategicdata.com.au (Geoff Crompton) Date: Thu, 02 Nov 2006 17:07:45 +1100 Subject: [Melbourne-pm] asking your server for hardware details Message-ID: <45498B31.9080101@strategicdata.com.au> Hi, Do people know of any handy CPAN modules that help in working out hardware details, for systems programming? I'm writing a script that will answer the following sort of questions, to build up a catalog of information about our servers: * how many hard drives does it have (non raid) * does it have a raid controller * how many hard drives are on the raid controller does it have * how many optical drives, and what sorts * how many floppy disk drives We run Debian and windows, so something that is cross platform is better. I've already found Sys::CPU, Sys::Hostname::FQDN. And I've found some modules that do network stuff, but they didn't give me what I needed, so I rolled my own, parsing ifconfig output. Perhaps someone has a more general answer? My goal is a YAML output hash, so I can integrate it with other stuff. -- Geoff Crompton Debian System Administrator Strategic Data +61 3 9340 9000 From ddick at aapt.net.au Thu Nov 2 11:32:09 2006 From: ddick at aapt.net.au (David Dick) Date: Fri, 03 Nov 2006 06:32:09 +1100 Subject: [Melbourne-pm] asking your server for hardware details In-Reply-To: <45498B31.9080101@strategicdata.com.au> References: <45498B31.9080101@strategicdata.com.au> Message-ID: <454A47B9.702@aapt.net.au> Geoff Crompton wrote: > Hi, > Do people know of any handy CPAN modules that help in working out > hardware details, for systems programming? > > I'm writing a script that will answer the following sort of questions, > to build up a catalog of information about our servers: > > * how many hard drives does it have (non raid) > * does it have a raid controller > * how many hard drives are on the raid controller does it have > * how many optical drives, and what sorts > * how many floppy disk drives > > We run Debian and windows, so something that is cross platform is better. > > I've already found Sys::CPU, Sys::Hostname::FQDN. And I've found some > modules that do network stuff, but they didn't give me what I needed, so > I rolled my own, parsing ifconfig output. > > Perhaps someone has a more general answer? My goal is a YAML output > hash, so I can integrate it with other stuff. > Hi Geoff, You might stand a good chance of getting that sort of information from windows via the WMI interface. Dave Roth has some examples such as http://www.roth.net/perl/scripts/scripts.asp?wmi-Generic.pl. With linux you might be able to get results from /proc, but i wouldn't expect you would be able to use it on bsd type machines (where /proc is usually unmounted) so unfortunately parsing ifconfig is probably the "best" solution. Best of luck -Dave From jarich at perltraining.com.au Thu Nov 2 21:33:00 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Fri, 03 Nov 2006 16:33:00 +1100 Subject: [Melbourne-pm] Meeting next week: Wednesday 8th November Message-ID: <454AD48C.4040904@perltraining.com.au> G'day everyone, Just a quick reminder that our regular monthly meeting will run next week on Wednesday 8th. You are welcome to come and encouraged to bring friends, family, co-workers and random people you find on the street. :) Date: Wednesday 8th November 2006 Time: 6:30pm Location: Level 8, 14 Blackwood Street, North Melbourne The downstairs doors may lock at 6:30pm. Ben will helpfully make sure that there is a note on the doors for a number you can call to be let in. Do not call Scott or myself as neither of us will be upstairs to let you in. Kirrily Robert has volunteered to present a talk on HTML::Mason on her idiosyncratic and slightly curmudgeonly views on web development with Mason. If you have a talk topic you'd like to give - for this meeting or for one in the future - please send it through to the list. We're always interested in more talks. If you know someone who might be interested in this meeting's talks. In fact, try to bring someone else along anyway, the more the merrier! Your friends, family and work colleagues are all invited! Attendance is free. Next Meeting ============ The next Perl Monger meeting will (probably) be on Wednesday, the 10th January 2007, and may be a lightning talk evening. More details yet to be decided). A social night, possibly combined with the PHP users group may be run during December. OSDClub ======= OSDClub will (probably) next run on the 14th February, instead of the regular Melbourne Perl Monger's Perl meeting. For talk topics and other information please visit: http://www.osdc.com.au/osdclub/index.html You are encouraged to volunteer to present a talk! -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From jarich at perltraining.com.au Thu Nov 2 22:07:08 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Fri, 03 Nov 2006 17:07:08 +1100 Subject: [Melbourne-pm] Meeting next week: Wednesday 8th November In-Reply-To: <6FA6124E9378214883CA93A54AED601D04969900@EMAIL.win.int.realestate.com.au> References: <6FA6124E9378214883CA93A54AED601D04969900@EMAIL.win.int.realestate.com.au> Message-ID: <454ADC8C.9000907@perltraining.com.au> Kirrily Robert wrote: > Um, actually, I don't think I can. Sorry if I gave the impression that > I was actively volunteering rather than just gauging interest. As it > happens I have some laptop problems and I'm going to be away the whole > Cup weekend, so I don't think I'm in any position to commit to anything > for Wednesday. > > Sorry. S'ok, I'm sorry I didn't follow you up on this sooner as well. Does anyone have any OSDC talks they want to practice? J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From krobert at realestate.com.au Thu Nov 2 21:52:21 2006 From: krobert at realestate.com.au (Kirrily Robert) Date: Fri, 3 Nov 2006 16:52:21 +1100 Subject: [Melbourne-pm] Meeting next week: Wednesday 8th November Message-ID: <6FA6124E9378214883CA93A54AED601D04969900@EMAIL.win.int.realestate.com.au> Kirrily Robert has volunteered to present a talk on HTML::Mason on her idiosyncratic and slightly curmudgeonly views on web development with Mason. Um, actually, I don't think I can. Sorry if I gave the impression that I was actively volunteering rather than just gauging interest. As it happens I have some laptop problems and I'm going to be away the whole Cup weekend, so I don't think I'm in any position to commit to anything for Wednesday. Sorry. K. From peter at machell.net Sat Nov 4 04:00:46 2006 From: peter at machell.net (Peter Machell) Date: Sat, 4 Nov 2006 22:00:46 +1000 Subject: [Melbourne-pm] SQL date calculations inside PERL Message-ID: <254507A3-0365-4139-ACE4-83DCD821CD7F@machell.net> The following is SQL I need to pump into an array. How do I do this without PERL seeing @foo as a global variable? I'm connecting with DBI:ODBC Thanks in advance, Peter. DECLARE @Date DATETIME; SET @Date = FLOOR(CONVERT(FLOAT, GETDATE())); SELECT CM_PATIENT.FIRST_NAME, CM_PATIENT.SURNAME, CM_PATIENT.PHONE_MOBILE, PRAC.Name, APPT.[When] FROM CM_PATIENT,PRAC,APPT WHERE CM_PATIENT.PATIENT_ID = APPT.PatientID AND APPT.PractitionerID = PRAC.PractitionerID AND APPT.[When] BETWEEN @Date + 1 AND @Date + 2 ORDER BY APPT.[When]; From daniel at rimspace.net Sat Nov 4 04:30:18 2006 From: daniel at rimspace.net (Daniel Pittman) Date: Sat, 04 Nov 2006 23:30:18 +1100 Subject: [Melbourne-pm] SQL date calculations inside PERL In-Reply-To: <254507A3-0365-4139-ACE4-83DCD821CD7F@machell.net> (Peter Machell's message of "Sat\, 4 Nov 2006 22\:00\:46 +1000") References: <254507A3-0365-4139-ACE4-83DCD821CD7F@machell.net> Message-ID: <878xir2y3p.fsf@rimspace.net> Peter Machell writes: > The following is SQL I need to pump into an array. How do I do this > without PERL seeing @foo as a global variable? I'm connecting with > DBI:ODBC Do you mean "how do I quote this so Perl doesn't interpret '@Date' as an array expression?" To do that you can either put it inside '' marks or escape using \ before the '@' character. If not please restate the question, since it isn't clear, I think. > DECLARE @Date DATETIME; > SET @Date = FLOOR(CONVERT(FLOAT, GETDATE())); "DECLARE \@Date DATETIME;" 'SET @Date = FLOOR(CONVERT(FLOAT, GETDATE()));' ...mostly, the fact that none of this contained the '@foo' literal made me think that you mean that as a generic term and '@Date' was the code in question. Regards, Daniel -- Digital Infrastructure Solutions -- making IT simple, stable and secure Phone: 0401 155 707 email: contact at digital-infrastructure.com.au http://digital-infrastructure.com.au/ From peter at machell.net Sat Nov 4 04:59:43 2006 From: peter at machell.net (Peter Machell) Date: Sat, 4 Nov 2006 22:59:43 +1000 Subject: [Melbourne-pm] SQL date calculations inside PERL In-Reply-To: <254507A3-0365-4139-ACE4-83DCD821CD7F@machell.net> References: <254507A3-0365-4139-ACE4-83DCD821CD7F@machell.net> Message-ID: On 04/11/2006, at 10:00 PM, Peter Machell wrote: > The following is SQL I need to pump into an array. How do I do this > without PERL seeing @foo as a global variable? Thanks to Alfie and Daniel for pointing me to PERL Quoting 101 - encapsulate in single quotes or escape with \ It's easy to stay a noob when you use PERL once in a blue moon. Peter. From Hamish.Carpenter at its.monash.edu.au Sun Nov 5 18:30:34 2006 From: Hamish.Carpenter at its.monash.edu.au (Hamish Carpenter) Date: Mon, 06 Nov 2006 13:30:34 +1100 Subject: [Melbourne-pm] Meeting next week: Wednesday 8th November In-Reply-To: <454ADC8C.9000907@perltraining.com.au> References: <6FA6124E9378214883CA93A54AED601D04969900@EMAIL.win.int.realestate.com.au> <454ADC8C.9000907@perltraining.com.au> Message-ID: <454E9E4A.9080603@its.monash.edu.au> I'd be happy to practice my talk (http://osdc2006.cgpublisher.com/proposals/49/index_html) its still very much alpha (no web 2.0 polish yet) but I'd love the chance for other people to have some input to making it more useful outside our university setting. hamish Jacinta Richardson wrote: > Does anyone have any OSDC talks they want to practice? From jarich at perltraining.com.au Thu Nov 9 17:42:43 2006 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Fri, 10 Nov 2006 12:42:43 +1100 (EST) Subject: [Melbourne-pm] OSDC 2006's tutorials Message-ID: <20061110014243.57013A81D3@teddybear.perltraining.com.au> Time is running out to register for tutorials at the Open Source Developers' Conference 2006 tutorial program: http://www.osdc.com.au/registration/index.html The tutorials run on the 5th December, followed by the technical program on the 6th - 8th December. Most tutorials include printed reference material. Our tutorial program is included below: Room 1 Room 2 9:00am Cascading Style Sheets Open Source Python GIS Hacks 12:30pm Lunch Lunch 1:30pm Test Web Apps with Perl Drupal Tutorial 3:00pm Afternoon tea Afternoon tea 3:30pm Intro to Perl Template::Toolkit Large Scale Web Apps A morning tea break will occur roughly half way through the the 9am - 12:30pm tutorials. For more information on what each tutorial covers, please visit: http://www.osdc.com.au/papers/tutorials.html Prices and information on how to register can be found at: http://www.osdc.com.au/registration/index.html You can help us make this conference be the best developers' conference this year just by turning up and participating! We look forward to sharing this great conference with you. If your business would like to benefit from exposure to many of Australia's best open source developers then perhaps you should consider sponsorship. We have a wide range of sponsorship options, to find out more information please visit: http://www.osdc.com.au/sponsors/index.html Jacinta Richardson OSDC Publicity Officer From peter at machell.net Wed Nov 15 00:10:50 2006 From: peter at machell.net (Peter Machell) Date: Wed, 15 Nov 2006 18:10:50 +1000 Subject: [Melbourne-pm] LWP::UserAgent to post to web form Message-ID: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> Newbie alert. Help appreciated. I'm trying to script data to send to a web form. Please point me in the right direction if LWP::UserAgent is not an appropriate way to do this. The code below is hitting the server but not sending a POST request. $ua returns LWP::UserAgent=HASH(0x82d0ab0) Thanks in advance, Peter. #!/usr/bin/perl use strict; use HTTP::Request::Common; use LWP::UserAgent; my($ua) = LWP::UserAgent->new; my($url) = 'http://foo.com/'; my($send) = $ua->request(POST $url, Content_Type => 'form-data', Content => [ userid => 'test', firstname => 'Test', ] ); From shlomif at iglu.org.il Wed Nov 15 02:24:08 2006 From: shlomif at iglu.org.il (Shlomi Fish) Date: Wed, 15 Nov 2006 12:24:08 +0200 Subject: [Melbourne-pm] LWP::UserAgent to post to web form In-Reply-To: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> References: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> Message-ID: <200611151224.09028.shlomif@iglu.org.il> On Wednesday 15 November 2006 10:10, Peter Machell wrote: > Newbie alert. Help appreciated. > > I'm trying to script data to send to a web form. > > Please point me in the right direction if LWP::UserAgent is not an > appropriate way to do this. > Well, LWP::UserAgent is an appropriate to do that. In many cases, however, WWW::Mechanize would be preferable. > The code below is hitting the server but not sending a POST request. > $ua returns LWP::UserAgent=HASH(0x82d0ab0) > Well, a few notes on the code: > Thanks in advance, > > Peter. > > > #!/usr/bin/perl > > use strict; > use HTTP::Request::Common; > use LWP::UserAgent; > > my($ua) = LWP::UserAgent->new; > You should really write my $ua = LWP::UserAgent->new; my ($ua) calls the function in list context and returns only the first element. my $ua calls it in scalar context. I don't think it makes much difference here, but it could yield to subtle bugs. > my($url) = 'http://foo.com/'; > Ditto. > my($send) = $ua->request(POST $url, > Content_Type => 'form-data', > Content => > [ > userid => 'test', > firstname => 'Test', > ] > ); You should use the $ua->post ( $url, \%form) method instead. Reading from the LWP::UserAgent POD document: <<<<<<< $ua->post( $url, \%form ) $ua->post( $url, \@form ) $ua->post( $url, \%form, $field_name => $value, ... ) This method will dispatch a "POST" request on the given $url, with %form or @form providing the key/value pairs for the fill-in form content. Additional headers and content options are the same as for the get() method. This method will use the POST() function from "HTTP::Request::Com mon" to build the request. See HTTP::Request::Common for a details on how to pass form content and other advanced features. >>>>>>>>> If something doesn't work you can trace the conversation using wireshark: http://www.wireshark.org/ Hope it helps, Shlomi Fish > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm -- --------------------------------------------------------------------- Shlomi Fish shlomif at iglu.org.il Homepage: http://www.shlomifish.org/ Chuck Norris wrote a complete Perl 6 implementation in a day but then destroyed all evidence with his bare hands, so no one will know his secrets. From guy at alchemy.com.au Thu Nov 16 03:06:14 2006 From: guy at alchemy.com.au (Guy Morton) Date: Thu, 16 Nov 2006 22:06:14 +1100 Subject: [Melbourne-pm] WebService::Mappoint In-Reply-To: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> References: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> Message-ID: <4015590B-AA12-49D1-BC6C-F68FCE7C2111@alchemy.com.au> Hi there Does anyone out there know anything about this module? It is a few years old and I suspect it no longer works with the later version of MapPoint Web Service. I hope I am wrong about this. I haven't managed to make it work so far using my test account. Guy From scottp at dd.com.au Thu Nov 16 13:46:26 2006 From: scottp at dd.com.au (Scott Penrose) Date: Fri, 17 Nov 2006 08:46:26 +1100 Subject: [Melbourne-pm] WebService::Mappoint In-Reply-To: <4015590B-AA12-49D1-BC6C-F68FCE7C2111@alchemy.com.au> References: <223906CB-781E-4D8F-8165-36BB0E7B09E6@machell.net> <4015590B-AA12-49D1-BC6C-F68FCE7C2111@alchemy.com.au> Message-ID: <758747BC-B370-491A-A3A8-3F6FDB6F61B4@dd.com.au> Unfortunately not, but I am interested to hear if you get it going. Scott On 16/11/2006, at 22:06, Guy Morton wrote: > Hi there > > Does anyone out there know anything about this module? It is a few > years old and I suspect it no longer works with the later version of > MapPoint Web Service. I hope I am wrong about this. I haven't managed > to make it work so far using my test account. > > Guy > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm -- * - * http://www.osdc.com.au - Open Source Developers Conference * - * Scott Penrose Welcome to the Digital Dimension http://www.dd.com.au/ scottp at dd.com.au Dismaimer: Contents of this mail and signature are bound to change randomly. Whilst every attempt has been made to control said randomness, the author wishes to remain blameless for the number of eggs that damn chicken laid. Oh and I don't want to hear about butterflies either. Please do not send me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html Microsoft is not the answer. It's the question. And the answer is no. From guy at alchemy.com.au Thu Nov 16 15:09:13 2006 From: guy at alchemy.com.au (Guy Morton) Date: Fri, 17 Nov 2006 10:09:13 +1100 Subject: [Melbourne-pm] LWP and Digest authentication Message-ID: <79854A32-617B-45BE-BEA3-82F29481300E@alchemy.com.au> Anyone know of a good tutorial for this? I'm not having much luck so far. Thanks Guy From cas at taz.net.au Thu Nov 16 16:07:33 2006 From: cas at taz.net.au (Craig Sanders) Date: Fri, 17 Nov 2006 11:07:33 +1100 Subject: [Melbourne-pm] LWP and Digest authentication In-Reply-To: <79854A32-617B-45BE-BEA3-82F29481300E@alchemy.com.au> References: <79854A32-617B-45BE-BEA3-82F29481300E@alchemy.com.au> Message-ID: <20061117000732.GB560@taz.net.au> On Fri, Nov 17, 2006 at 10:09:13AM +1100, Guy Morton wrote: > Anyone know of a good tutorial for this? I'm not having much luck so > far. see the lwptut man page for more details, but in summary it is like this: use LWP; my $browser = LWP::UserAgent->new; $browser->credentials( 'servername:portnumber', 'realm-name', 'username' => 'password' ); this should work for Basic and Digest auth. (note that lwptut also mentions that neither authentication nor cookies are available for LWP::Simple). see also LWP::UserAgent which mentions this: $ua->credentials( $netloc, $realm, $uname, $pass ) Set the user name and password to be used for a realm. It is often more useful to specialize the get_basic_creden- tials() method instead. (it's interesting that the username and password pair are a hash in the lwptut example, and just members of a list in the man page. dunno which is right, or if both are right) and this: $ua->get_basic_credentials( $realm, $uri, $isproxy ) This is called by request() to retrieve credentials for documents by Basic or Digest Authentication. The arguments passed in is the $realm provided by the server, the $uri and a boolean flag to indicate if this is authentication against a proxy server. The method should return a username and password. It should return empty list to abort the authentication resolu- tion attempt. Subclasses can override this method to prompt the for the information. An example of this can be found in "lwp-request" program distributed with this library. The base implementation simply checks a set of pre-stored member, set up with the credentials() method. hope that helps. craig -- craig sanders (part time cyborg) From leif.eriksen at hpa.com.au Thu Nov 16 16:11:16 2006 From: leif.eriksen at hpa.com.au (leif.eriksen at hpa.com.au) Date: Fri, 17 Nov 2006 11:11:16 +1100 Subject: [Melbourne-pm] LWP and Digest authentication Message-ID: <6462CBB658614845A7702E3798807698015740AE@exhnat2.nsw.hpa> > (it's interesting that the username and password pair are a hash in the lwptut example, and just members of > a list in the man page. dunno which is right, or if both are right) The '=>' is acting in it '99%-comma' role - they are effectively exactly the same. L -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.14.6/535 - Release Date: 15/11/2006 ********************************************************************** IMPORTANT The contents of this e-mail and its attachments are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you received this e-mail in error, please notify the HPA Postmaster, postmaster at hpa.com.au, then delete the e-mail. This footnote also confirms that this e-mail message has been swept for the presence of computer viruses by Ironport. Before opening or using any attachments, check them for viruses and defects. Our liability is limited to resupplying any affected attachments. HPA collects personal information to provide and market our services. For more information about use, disclosure and access see our Privacy Policy at www.hpa.com.au ********************************************************************** From cas at taz.net.au Thu Nov 16 16:31:05 2006 From: cas at taz.net.au (Craig Sanders) Date: Fri, 17 Nov 2006 11:31:05 +1100 Subject: [Melbourne-pm] LWP and Digest authentication In-Reply-To: <6462CBB658614845A7702E3798807698015740AE@exhnat2.nsw.hpa> References: <6462CBB658614845A7702E3798807698015740AE@exhnat2.nsw.hpa> Message-ID: <20061117003105.GC560@taz.net.au> On Fri, Nov 17, 2006 at 11:11:16AM +1100, leif.eriksen at hpa.com.au wrote: > > (it's interesting that the username and password pair are a hash > > in the lwptut example, and just members of a list in the man page. > > dunno which is right, or if both are right) > > The '=>' is acting in it '99%-comma' role - they are effectively > exactly the same. uhh, yeah...doh! of course. craig -- craig sanders (part time cyborg) From pjf at perltraining.com.au Tue Nov 21 16:42:48 2006 From: pjf at perltraining.com.au (Paul Fenwick) Date: Wed, 22 Nov 2006 11:42:48 +1100 Subject: [Melbourne-pm] Melbourne Massive - Web Festivities, 13th December 6pm Message-ID: <45639D08.3050809@perltraining.com.au> G'day Melbourne Perl Mongers, I'm very pleased to invite you all to Melbourne Massive, a social/networking event for Melbourne's web community. Features include: * Free entry * Free food * Free drink * Door prizes * DJs * Hundreds of cool individuals from Melbourne's web community[1]. You can find more information at: http://melbournemassive.com/about/ Note that while entry is free, registration before the event is required. Hope to see you there, Paul [1] Actual numbers may vary. -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From tconnors+pmmelb at astro.swin.edu.au Tue Nov 21 21:11:15 2006 From: tconnors+pmmelb at astro.swin.edu.au (Tim Connors) Date: Wed, 22 Nov 2006 16:11:15 +1100 (EST) Subject: [Melbourne-pm] Camel POOP -- initialisation of an object Message-ID: I'm just learning about camel POOP, and came across a problem trying to initialise an object. I'm using a method presented in `man perltoot` to construct an object that has AUTOLOADed accessor methods. This is my constructor, as it is working: sub new { my %fields = ( current_iter_index => 0, fibre_number => undef, iteration => [], fibres_index => undef, iter_time => undef, iter_nums => undef, from => undef, to => undef, move_type => undef, in_tol => undef, ); my ($class, %args) = (@_); $class = ref($class) || $class; my $self = { _public => \%fields, %fields, }; bless($self, $class); my @keys = sort keys(%args); foreach my $key (@keys) { $self->$key($args{$key}); #initialise the known values } return $self; } It works fine. The @iteration array is constructed fine, and I can go access it later. However, if I follow the method outlined in the manpage, I would have put that %fields hash before the subroutine (at the top of my .pm file, to make it super easy to add fields and initialise them properly later on). All the fields get initialised fine, and I can modify each field in each object, all except the @iteration array. This array is shared for all instantiations of my object. Modify one, modify them all. It's pretty easy to understand why -- I have only constructed the one array, and the array ref ends up in the %fields, which ends up in my object. Simply moving %fields to within the scope of new is a workaround, in that each %field is new. But is there another way? I guess I could just initialise iteration to undef -- I think the first push onto the array will construct an array, right? But I'm thinking about documentation within the code, here. I want it to be obvious that this field is a ref to an array, and always will be a ref to an array. -- Tim Connors From jarich at perltraining.com.au Tue Nov 21 22:07:18 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Wed, 22 Nov 2006 17:07:18 +1100 Subject: [Melbourne-pm] Camel POOP -- initialisation of an object In-Reply-To: References: Message-ID: <4563E916.5000208@perltraining.com.au> Tim Connors wrote: > my ($class, %args) = (@_); > $class = ref($class) || $class; > my $self = { > _public => \%fields, > %fields, > }; I'm not quite sure what this is supposed to be doing. Why are you storing both a reference to %fields and the contents of %fields? How will you keep them both in sync? Anyway, the answer to your question may be found in Storable's dclone (deep clone) subroutine: use Storable qw(dclone); my $self = { _public => dclone(\%fields), %{ dclone \%fields }, }; For example, the following code provides 4 different array references for "c" and thus, should work as you need it to: #!/usr/bin/perl -w use strict; use Storable qw(dclone); use Data::Dumper; my %fields = ( a => 1, b => undef, c => [], ); sub new { my $self = { _public => dclone(\%fields), %{ dclone \%fields }, }; return $self; } my $foo = new(); my $bar = new(); print Dumper $foo; push @{$foo->{c}}, (1, 2, 4); push @{$foo->{_public}{c}}, (10, 11, 12); print Dumper $foo; print Dumper $bar; > my @keys = sort keys(%args); > foreach my $key (@keys) { > $self->$key($args{$key}); #initialise the known values > } > return $self; I'm not quite sure why you sort the keys before doing this loop, it doesn't seem to gain you anything. Perhaps: foreach my $key ( keys %args ) { $self->$key($args{$key} ); } All the best, J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From tconnors+pmmelb at astro.swin.edu.au Tue Nov 21 22:20:32 2006 From: tconnors+pmmelb at astro.swin.edu.au (Tim Connors) Date: Wed, 22 Nov 2006 17:20:32 +1100 (EST) Subject: [Melbourne-pm] Camel POOP -- initialisation of an object In-Reply-To: <4563E916.5000208@perltraining.com.au> References: <4563E916.5000208@perltraining.com.au> Message-ID: On Wed, 22 Nov 2006, Jacinta Richardson wrote: > Tim Connors wrote: > > > my ($class, %args) = (@_); > > $class = ref($class) || $class; > > my $self = { > > _public => \%fields, > > %fields, > > }; > > I'm not quite sure what this is supposed to be doing. Why are you storing both > a reference to %fields and the contents of %fields? How will you keep them both > in sync? It comes in handy when you define a sub AUTOLOAD{}. I can add all the private fields to $obj that I want, but if it wasn't in %fields, then it won't be in the hash held within $obj->_public, and AUTOLOAD{} says "sorry, variable doesn't exist or is privatge; can't modify". Poor mans datahiding! (see man perltoot). > > my @keys = sort keys(%args); > > foreach my $key (@keys) { > > $self->$key($args{$key}); #initialise the known values > > } > > return $self; > > I'm not quite sure why you sort the keys before doing this loop, it doesn't seem > to gain you anything. Perhaps: > > foreach my $key ( keys %args ) { > $self->$key($args{$key} ); > } > Yeah I know - I snipped some irrevant code. -- Tim Connors http://site.aao.gov.au/twc From jarich at perltraining.com.au Tue Nov 28 20:16:34 2006 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Wed, 29 Nov 2006 15:16:34 +1100 (EST) Subject: [Melbourne-pm] OSDC 2006 is on next week 5th-8th December Message-ID: <20061129041634.97888A8460@teddybear.perltraining.com.au> The Open Source Developers' Conference 2006 is running next week on Tuesday 5th (tutorials) - Friday 8th December. It's shaping up to be the biggest OSDC we've ever run! If you haven't booked your place yet, you can book at: http://www.osdc.com.au/registration/index.html We encourage you to invite fellow programmers to join us at this conference. Featured languages include C, C++, .Net (and Mono), Java, Perl, PHP, Python and more. A few places are still available on most tutorials. The program is now online and can be found at: http://osdc2006.cgpublisher.com/program.html The conference will be held at: Monash University, Caulfield Campus 900 Dandenong Road, Caulfield East This location is accessible by train (Caulfield Station) and tram (Number 3 - East Malvern). Parking is available at the Caulfield Racecourse in the white bays for $5.50 per day. Hourly parking is also available on campus in the Building J multi-storey car park to a daily maximum of $8.00. Registration will start at 8am on Wednesday and 8:30am on both the Thursday and Friday. The technical conference material will start at 9am on all three days and finish at 5:30pm. Registration will be held in the foyer of Level 3, K building. A map of the university and surrounds can be found at: http://www.monash.edu.au/pubs/maps/2-Caulfieldcolour.pdf The conference dinner will be held at the Griff Inn which is on the ground level of the K building. Dinner starts at 6pm. Conference attendees receive a dinner ticket with their registration. Extra tickets can be purchased for non-conference attendees. Morning tea, lunch and afternoon tea will be served each day, along with tea, coffee, juices and water. An expresso machine will be available for those who desire "real coffee", or hot chocolate although a small fee will apply to cover costs. We still need a few extra people to help out at the registration desk throughout the conference. If you'd like to get free entry in return for missing out on some of the conference, please contact the committee on committee at osdc.com.au I look forward to sharing this great event with you. Jacinta