On Mar 26, 2014, at 6:30 PM, Benjamin Fernandis <benjo11...@gmail.com> wrote:
> Hi, > > I am new with perl and we have virtual machines in our infra. i want to use > perl sys::virt module to manage them, means to shutdown / start vm by script > and for that i wrote below small code. > > #!/usr/bin/perl > # > use strict; > use warnings; > > use Sys::Virt; > > > my $vmm = Sys::Virt->new(uri => "qemu:///system"); > > my @domains = $vmm->list_domains(); > > foreach my $dom (@domains) { > print "Domain ", $dom->get_id, " ", $dom->get_name, "\n"; > } > my $vm = 'win7'; > > $vm = $vmm->destroy(); > > > and when i run it , i got below error. > > Domain 10 win7 > Can't locate object method "destroy" via package "Sys::Virt" at vm.pl line 18. > > can you please guide me that where i made mistake. please correct me if > something syntax problem or. > > Thanks > Ben That error message indicates that the Sys::Virt class has no method called ‘destroy’. That corresponds with the documentation of the class on cpan.org. Why are you calling that method? Are you running the latest version of the module? The syntax of the program is fine, as indicated by the fact that it does compile. However, it is unnecessary to assign a value to $vm when it is declared, and then immediately overwrite that value with the return value of $vmm->destroy(). -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/