Hi Folks if i take the code outside a package it works perfectly. Once put into a package i do the following which works great
my $get_account = accounts->new($ss_username,$ss_password); the call works fine and getAccountInfo gets called. The only thing that isn't working is the call to ret_data2 once curl is complete. The code works outside a package..just not within a package...the ret_data2 is never called even though $curl->errbuff is 0. Your thoughts? use WWW::Curl::Easy; use Data::Dumper; use XML::DOM; { package accounts; my $ss_username; my $ss_account_id; my $ss_email_address; my $ss_password; my $self = { ss_username => $ss_username, ss_password => $ss_password, ss_account_id => $ss_account_id, ss_email_address => $ss_email_address }; # Anonymous hash reference holds instance attributes sub new { my($class, $ss_username,$ss_password) = @_; # Class name is in the first parameter bless($self, $class); # Say: $self is a $class my $ret_list = getAccountInfo(); print $ret_list."\n"; return $self; } sub getAccountInfo { my @authHeader = ('Accept: application/xml', 'Content-Type: application/xml'); # Setting the options my $curl = new WWW::Curl::Easy; $curl->setopt(CURLOPT_HEADER,0); $curl->setopt(CURLOPT_HTTPHEADER, \...@authheader); $curl->setopt(CURLOPT_SSL_VERIFYPEER, 0); $curl->setopt(CURLOPT_USERPWD, 'myusername:mypassword'); $curl->setopt(CURLOPT_URL, "https://app.streamsend.com/ audiences"); $curl->setopt(CURLOPT_RETURNTRANSFER,1); $curl->setopt(CURLOPT_WRITEFUNCTION,\&ret_data2); my $result = $curl->perform(); my $err = $curl->errbuff; print "err = ".$err."\n"; $curl->dispose(); } ######################################################################## # ret_data2 # is called once curl is completed # the xml statement above is processed # we only need the id, and email address ######################################################################## sub ret_data2 { print "ret_data\n"; my $chunk = shift; #this will get the xml print $chunk; $xp = new XML::DOM::Parser(); $doc = $xp->parse($chunk); $self->{ss_account_id} = $doc->getElementsByTagName("id")->item(0)- >getFirstChild->getNodeValue; $self->{ss_email_address} = $doc->getElementsByTagName("from-email- address")->item(0)->getFirstChild->getNodeValue; return 0; } } 1; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/