On Sunday, August 17, 2003, at 06:15 AM, David T-G wrote:

Hi, all --

Howdy.


I've gotten rusty and so I'm back again as a rank amateur :-)

I have a script that will make a database connection, pull out some rows,
repeatedly generate personalized message bodies, and send those bodies.


I'm stuck at the generation part.  I want to pass a couple of hashes to
my function but it's giving me fits -- and if I read Programming Perl
correctly then I can't do what I want to.

My code looks like

...
41 ### loop thru list
42 while ( my @row = $result->fetchrow_array )
43 {
44 my ($ascii, $html, $flag, $email, $fn, $ln) = @row ;
45 my $body =
46 &parseit
47 (
48 {ASCII=>$ascii,HTML=>$html},
49 {flag=>$flag,EMAIL=>$email,NAME_FIRST=>$fn,NAME_LAST=>$ln}
50 ) ;

This is passing two hash references, just like you want. Drop the ampersand on the call though, we don't do that anymore. ;)


     51 }
  ...
     60 # parse function
     61 #sub parseit(my %template,my %userdata)
     62 sub parseit
     63 {
     64   my (%template,%userdata) = @_ ;

You passed in references, not hashes. Try getting them back like this, to minimize the amount of work you have to do with the references:


sub parse {
        my %template = %{shift()};
        my %userdata = %{shift()};
        #...
}

     65   print "template is .$template.\n";    ###
     66 }
  ...

and at this point, as you can see, I'm having some trouble trying to get
the data there; template is always uninitialized. I haven't even gotten
close to returning anything :-/


Given what I *want* to do (pass in two versions of a text template as
well as a bunch of user data and get out the proper template with all of
the user data spliced in), how should I approach it?



TIA & HAND


praying for a quick response,
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


<mime-attachment>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to