in reply to Attempting to read file name into my XML Parsing Object

When you call a method (class or instance) $_[0] contains the thing the method was called upon. In your case this is $obj, and $_[1] would contain the path you passed as the argument. Your code makes a new instance inside the method itself, then returns that new instance.

To put it bluntly, you've got some confusion about OO in Perl. See perlboot and the other OO tutorials for more details.

Replies are listed 'Best First'.
Re^2: Attempting to read file name into my XML Parsing Object
by Cappadonna3030 (Sexton) on Apr 26, 2006 at 19:39 UTC

    Cool. I took a little time to look over my Advance Perl Programming Book (the O'Reilly Panther book). I got it working for the most part. However, it appears that I'm having array errors.

    To create a list of hospital staff, my method parse through the staff list and records their first and last name into an array. This array is then reference in a hash, using their role (X-ray Tech, physician, Nurse) as a key.

    foreach $workerbee($doc->getElementsByTagName('CathStaff')) { print "Staff = $s1, $s2\n"; $s1 = $workerbee->getElementsByTagName('LastName')->item(0 +)->getFirstChild->getNodeValue; $s2 = $workerbee->getElementsByTagName('FirstName')->item( +0)->getFirstChild->getNodeValue; $s3 = $workerbee->getAttribute('Role'); @staff = ($s1,$s2); print "Staff = $s1, $s2\n"; my $arrayref = \@staff; $staff_set{$s3} = $arrayref; }

    Now my main loop is this:

    !/usr/bin/perl -w use XML::DOM; use CathRecord; ### Create New Object my $file = "H:/My Documents/files/mfrTESTa.XML"; my $obj = CathRecord->new(); my $ref = CathRecord::CamPatData($obj,$file); print"\n"; my $hashref = $ref->{STAFF}; foreach my $inst(keys %$hashref) { my $aih = $$hashref{$inst}; print "$inst: @$aih\n"; }

    I get this is a result:

    Staff = Joicelan, Rob Staff = Zdoctor, test Staff = Zdoctor, test Staff = Smith, Fred Staff = Smith, Fred Staff = Jones, Bill Staff = Jones, Bill Staff = Nelson, Jim Staff = Nelson, Jim Staff = Fellowlast, Fellowfirst Staff = Fellowlast, Fellowfirst Staff = fellowsecond, fred Staff = fellowsecond, fred Staff = rusoo123456789012, mike56789012345 Circ: rusoo123456789012 mike56789012345 Recording: rusoo123456789012 mike56789012345 Fellow: rusoo123456789012 mike56789012345 Scrub: rusoo123456789012 mike56789012345 Assisting_MD: rusoo123456789012 mike56789012345 Other: rusoo123456789012 mike56789012345 Rad: rusoo123456789012 mike56789012345 Physician: rusoo123456789012 mike56789012345

    So what's up with that?