From apollock at bit.net.au Thu Sep 9 01:35:29 1999 From: apollock at bit.net.au (Andrew Pollock) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] I need a little bit of help here... Message-ID: <004a01befa8d$824f7250$575e12cb@minotaur.bit.net.au> Hi, Packages are foreign to me, and we've purchased a support tracking system written in Perl (nice little Australian made job called DTS) and I'm trying to hack it a little bit to add some extra functionality. It actually comes with a "library" for site-specific things which it runs and that's where I'm trying to add some extra functionality. elsif ($evtype == $main::EVENT_EMAIL) { # Report is being modified by receiving mail # arg1 is \%to, arg2 is \%from &main::sendMail($$to{assigned}, "received mail about $$to{id}", "DTS has received email about report $$to{id}"); This is the snippet of code that is relevant. The sendMail subroutine is defined elsewhere and takes the following arguments: local ($address, $subject, $message, $from, $replyTo) = @_; The actual invocation of sendMail was given to me by the author of the system, but it's not working as expected and while I was waiting on a reply back from him, I thought I'd play around myself. The bit that is confusing me is the double dollar signs in front of the "to" and the "id" and the reference to the "to" and "from" hashes with a backslash in front of them. Can anyone with more Perl clue than myself shed any light on this? Andrew ---- Andrew Pollock Technical Director apollock@bit.net.au http://staff.bit.net.au/apollock Brisbane Internet Technology Pty Ltd. From r.buckland at qut.edu.au Sun Sep 12 00:39:33 1999 From: r.buckland at qut.edu.au (Ramon Buckland) Date: Wed Aug 4 23:59:06 2004 Subject: [BNE-PM] I need a little bit of help here...] Message-ID: <37DB3C95.C7C95751@qut.edu.au> -------- Original Message -------- Subject: Re: [BNE-PM] I need a little bit of help here... Date: Sun, 12 Sep 1999 15:37:41 +1000 From: Ramon Buckland To: Andrew Pollock References: <004a01befa8d$824f7250$575e12cb@minotaur.bit.net.au> Hi Andrew .. I noticed you haven't had a reply (well not comming back through the list anyways) Here is what I know (anyone may sure well correct me) If you pass \$to to a function .. you are (yep) passing the reference. the address if you like to the var $to to get the value from the reference .. you would do a ${$ref} if its a scalar @{$ref} if its a list (passed like \@arry) %{$ref} if its a hash (passed like \%hash) AND the beauty you can also in most situations.. negate the {}'s like $$ref @$ref %$ref An Example #!/usr/bin/perl $test = 'whoo hoo'; $ref = \$test; print "direct -> ". $test ."\n by reference -> " . $$ref ."\n"; $test = 'whoo hoo'; Does that help ? > > elsif ($evtype == $main::EVENT_EMAIL) > { > # Report is being modified by receiving mail > # arg1 is \%to, arg2 is \%from > > &main::sendMail($$to{assigned}, "received mail about > $$to{id}", > "DTS has received email about report $$to{id}"); > > This is the snippet of code that is relevant. > > The sendMail subroutine is defined elsewhere and takes the following > arguments: > > local ($address, $subject, $message, $from, $replyTo) = @_; > > The actual invocation of sendMail was given to me by the author of the > system, but it's not working as expected and while I was waiting on a reply > back from him, I thought I'd play around myself. The bit that is confusing > me is the double dollar signs in front of the "to" and the "id" and the > reference to the "to" and "from" hashes with a backslash in front of them. -- Ramon Buckland, System Administrator, Facilities Support Services Phone: 07 3864 1289 Fax: 07 3864 1823 Mobile: 0414 27 1289 (x6070) Email: r.buckland@qut.edu.au http: www.fss.qut.edu.au From r.buckland at qut.edu.au Sun Sep 12 22:49:17 1999 From: r.buckland at qut.edu.au (Ramon Buckland) Date: Wed Aug 4 23:59:06 2004 Subject: [BNE-PM] I need a little bit of help here... References: <003901befd82$65b2e030$575e12cb@minotaur.bit.net.au> Message-ID: <37DC743D.9A57399D@qut.edu.au> Hi Andrew, here is one that forced me to learn what the hell it all meant.... the result from selectall_arrayref (from DBI module) The sort line was what I had to create ... ----8<------------------8<-------------8<---------- ... my $array_ref = $dbh->selectall_arrayref($sql); # array_ref: a reference to an array which is a list of references # to arrays # now let's sort it # looks easy now that I got it .. but heck I burst a few brain cells!! my @sorted = sort { $$a[0] cmp $$b[0] } @$array_ref; # now @sorted is an array of references to arrays! # that is what I want! ... ----8<------------------8<-------------8<---------- Funny thing Is .. I should have sorted the list in the SQL statement . ahh well .. I'll die Typing! Thought you'd like to see that cheers > > > > Hi Andrew .. > > > > I noticed you haven't had a reply (well not comming > > back through the list anyways) > > > > Here is what I know (anyone may sure well correct me) > > > > If you pass \$to to a function .. > > you are (yep) passing the reference. the address if you like to the var > > $to > > > > to get the value from the reference .. you > > would do a > > > > ${$ref} if its a scalar > > @{$ref} if its a list (passed like \@arry) > > %{$ref} if its a hash (passed like \%hash) > > > > AND the beauty > > > > you can also in most situations.. negate the {}'s > > like > > > > $$ref > > @$ref > > %$ref > > > > An Example > > #!/usr/bin/perl > > > > $test = 'whoo hoo'; > > $ref = \$test; > > print "direct -> ". $test ."\n by reference -> " . $$ref ."\n"; > > $test = 'whoo hoo'; > > > > > > > > Does that help ? > > > > > > > > > > elsif ($evtype == $main::EVENT_EMAIL) > > > { > > > # Report is being modified by receiving mail > > > # arg1 is \%to, arg2 is \%from > > > > > > &main::sendMail($$to{assigned}, "received mail about > > > $$to{id}", > > > "DTS has received email about report $$to{id}"); > > > > > > This is the snippet of code that is relevant. > > > > > > The sendMail subroutine is defined elsewhere and takes the following > > > arguments: > > > > > > local ($address, $subject, $message, $from, $replyTo) = @_; > > > > > > The actual invocation of sendMail was given to me by the author of the > > > system, but it's not working as expected and while I was > > waiting on a reply > > > back from him, I thought I'd play around myself. The bit that > > is confusing > > > me is the double dollar signs in front of the "to" and the "id" and the > > > reference to the "to" and "from" hashes with a backslash in > > front of them. > > > > -- > > Ramon Buckland, System Administrator, Facilities Support Services > > Phone: 07 3864 1289 Fax: 07 3864 1823 Mobile: 0414 27 1289 (x6070) > > Email: r.buckland@qut.edu.au http: www.fss.qut.edu.au > > > > -- Ramon Buckland, System Administrator, Facilities Support Services Phone: 07 3864 1289 Fax: 07 3864 1823 Mobile: 0414 27 1289 (x6070) Email: r.buckland@qut.edu.au http: www.fss.qut.edu.au From apollock at bit.net.au Mon Sep 13 03:00:17 1999 From: apollock at bit.net.au (Andrew Pollock) Date: Wed Aug 4 23:59:06 2004 Subject: [BNE-PM] Anyone played with DB_File? Message-ID: <00d101befdbe$04b559c0$575e12cb@minotaur.bit.net.au> Hi again, Has anyone played with DB_File very much? I'm trying to talk to a Sendmail 8.9.x (libdb2) hash, and I'm not having much success. use DB_File; tie %aliases, 'DB_File', "/etc/aliases", "RDONLY", 0640, $DB_HASH || die "Couldn't do it: $!\n"; foreach (%aliases) { print "$_ = %aliases{$_}\n"; } untie %aliases; It doesn't die, but it doesn't work either... Andrew ---- Andrew Pollock Technical Director apollock@bit.net.au http://staff.bit.net.au/apollock Brisbane Internet Technology Pty Ltd. From Peter.Freiberg at env.qld.gov.au Tue Sep 14 00:37:22 1999 From: Peter.Freiberg at env.qld.gov.au (Peter Freiberg) Date: Wed Aug 4 23:59:06 2004 Subject: [BNE-PM] Anyone played with DB_File? References: <00d101befdbe$04b559c0$575e12cb@minotaur.bit.net.au> Message-ID: <37DDDF12.45696571@env.qld.gov.au> Hello Andrew, I'm not sure whether this will fix your problem, as I haven't used DB_File. Andrew Pollock wrote: > tie %aliases, 'DB_File', "/etc/aliases", "RDONLY", 0640, $DB_HASH || die > "Couldn't do it: $!\n"; > foreach (%aliases) { > print "$_ = %aliases{$_}\n"; I think these last two lines should be foreach (keys %aliases) { print "$_ = $aliases{$_}\n"; It looks to me like the hash hasn't been addressed correctly. regards, Peter. -- ---------------------------------------------- Peter Freiberg Information Support Officer (Web) Environmental Protection Agency Tel: 07 3227 8954 Fax: 07 3227 8455 E-mail: Peter.Freiberg@env.qld.gov.au Visit us online at http://www.env.qld.gov.au ----------------------------------------------