Net::BitTorrent

…brings BitTorrent to Perl! It works pretty much everywhere, depends only on core modules, and it's easy to use.

Net::BitTorrent development is hosted by GitHub. The official support channel is, #net-bittorrent on IRC but there's also a mailing list where users can seek assistance and an issue tracker for bug reports. To stay up to date with development, follow the project on Twitter or skim my blog-like thing.

Several example scripts come with the distribution on CPAN but since you asked nicely, here's a quick demonstration of that easy I mentioned earlier.

  1. #!perl -w
  2.  
  3. # synopsis.pl - A very brief example
  4.  
  5. use Net::BitTorrent;
  6. my $client = Net::BitTorrent->new( );
  7.  
  8. $client->on_event(
  9. q[piece_hash_pass],
  10. sub hash_pass {
  11. my ($self, $args) = @_;
  12. printf(qq[pass: piece number %04d of %s\n],
  13. $args->{q[Index]}, $args->{q[Torrent]}->infohash);
  14. }
  15. );
  16.  
  17. my $torrent = $client->add_torrent({Path => q[a.legal.torrent]})
  18. or die q[Cannot load .torrent];
  19.  
  20. $torrent->hashcheck; # Verify any existing data
  21.  
  22. $client->do_one_loop( ) while 1;

If you find Net::BitTorrent useful, feel free to support the project with donations; code is welcome from developers and cash is welcome from everyone.

Fork me on GitHub