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 attrib +utes sub new { my($class, $ss_username,$ss_password) = @_; # Class name is i +n 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 ###################################################################### +## 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;

In reply to Perl Package & Curl by jbowshaw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.