I'm trying to extract the SHA1 hashes out of a .torrent file using Net::BitTorrent::File, among other information, but can't seem to figure out how to get them. I keep getting binary data, not the ascii hash. Can anyone tell me what I'm doing wrong here?
#!/usr/bin/perl use strict; use warnings; use Convert::Bencode qw(bencode bdecode); use Net::BitTorrent::File; use Data::Dumper; my $file = shift; my $torrent = new Net::BitTorrent::File ($file); $torrent or die("Couldn't load torrent file"); # name print "name : ".$torrent->name()."\n"; # get the info hash my $info = $torrent->info(); # piece length my $piece_len = $info->{'piece length'}; print "piece length is : ".$piece_len."\n"; # pieces *** my $pieces = $info->{'pieces'}; my @pieces_array = (); # Seperate into 20-byte pieces while ($pieces ne "") { my $piece = substr($pieces, 0, 20); push(@pieces_array, $piece); $pieces = substr($pieces, 20); } foreach (@pieces_array) { print "piece : ".$_."\n"; } -- I'm nerdy in the extreme and whiter than sour cream -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/