home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libnet-dbus-perl / examples / example-client.pl < prev    next >
Encoding:
Perl Script  |  2008-02-20  |  823 b   |  36 lines

  1. #/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. use Net::DBus;
  7. use Carp qw(cluck carp confess);
  8. #$SIG{__WARN__} = sub { cluck $_[0] };
  9. #$SIG{__DIE__} = sub { confess "[". $_[0] ."]"};
  10.  
  11. my $bus = Net::DBus->session();
  12.  
  13. my $service = $bus->get_service("org.designfu.SampleService");
  14. my $object = $service->get_object("/SomeObject");
  15.  
  16. my $list = $object->HelloWorld("Hello from example-client.pl!");
  17.  
  18. print "[", join(", ", map { "'$_'" } @{$list}), "]\n";
  19.  
  20. my $tuple = $object->GetTuple();
  21.  
  22. print "(", join(", ", map { "'$_'" } @{$tuple}), ")\n";
  23.  
  24. my $dict = $object->GetDict();
  25.  
  26. print "{", join(", ", map { "'$_': '" . $dict->{$_} . "'"} keys %{$dict}), "}\n";
  27.  
  28. if (0) {
  29.     $object->name("John Doe");
  30.     $object->age(21);
  31. #$object->email('john.doe@example.com');
  32.     
  33.     print $object->name, " ", " ", $object->email, "\n";
  34.  
  35. }
  36.