lefty29er has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks, I have a script created to use SOAP::Lite and update a Cisco CM DB via XML. I need to gather data from a file/CSV to pull the device name and description into the code below as a variable (then loop ~3000 times). Any suggestions on how to accomplish this? Here's my code to update the phone description:
#!/usr/bin/perl + use SOAP::Lite; use Data::Dumper; my $cucmip = "10.186.78.4"; my $axl_port = "8443"; my $user = "PerlAXL"; my $password = "Pa$$word"; my $axltoolkit = "AXLAPI.wsdl"; BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ($user => $password) }; } my $cm = new SOAP::Lite encodingStyle => '', uri => "$axltoolkit", proxy => "https://$cucmip:$axl_port/axl/" ; my $res = $cm->updatePhone( SOAP::Data->name('name' => 'SEP123456123456'), SOAP::Data->name('lines' => SOAP::Data->name('line' => SOAP:: +Data->name('index' => '1'), SOAP: +:Data->name('description' => 'Perl Rocks') ) ) ); unless ($res->fault) { } else { print join ', ', $res->faultcode, $res->faultstring; }
I'm new to Perl but learning as I go. Any help is appreciated! Thanks

Replies are listed 'Best First'.
Re: Get data from file and loop
by lefty29er (Novice) on Oct 28, 2011 at 02:53 UTC
    UPDATE: I ended up using the text split function to accomplish this. Here's the code at this point, which updates a handful of descriptions on the CUCM in about 1 second!
    #!/usr/bin/perl + use SOAP::Lite; my $cucmip = "192.168.10.30"; #Home Lab my $axl_port = "8443"; my $user = "PerlAXL"; my $password = "Pa$$word"; my $axltoolkit = "AXLAPI.wsdl"; $start=time(); BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ($user => $password) }; } my $cm = new SOAP::Lite encodingStyle => '', uri => "$axltoolkit", proxy => "https://$cucmip:$axl_port/axl/" ; open (FILE, 'CUCM.txt'); while (<FILE>){ chomp; ($name, $description) = split ("\t"); { my $res = $cm->updatePhone( SOAP::Data->name('name' => "$name"), SOAP::Data->name('lines' => SOAP::Data->name('line' => SOAP:: +Data->name('index' => '1'), SOAP: +:Data->name('description' => "$description") ) ) ); unless ($res->fault) { } else { print join ', ', $res->faultcode, $res->faultstring; }}} close (FILE); $end = time(); print "That took Perl ", ($end - $start), " second(s) to update\n"; exit;
    Thanks,