[BNE-PM] I need a little bit of help here...

Ramon Buckland r.buckland at qut.edu.au
Sun Sep 12 22:49:17 CDT 1999


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 at qut.edu.au http: www.fss.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 at qut.edu.au http: www.fss.qut.edu.au
<http://www.fss.qut.edu.au/>



More information about the Brisbane-pm mailing list