My final working code:
sub import_key {
my ($file) = @_;
my $theirs = new Crypt::OpenPGP::KeyRing( Filename => $file )
|| die Crypt::OpenPGP::KeyRing->errstr;
$theirs->read();
my $change;
foreach my $block ($theirs->blocks) {
my $found;
foreach ($pubring->blocks) {
if ($_->key()->key_id_hex() eq $block->key()->key_id_hex()) {
printf "key %s: not changed\n", block->key()->key_id_hex();
$found++;
last;
}
}
if (not $found) {
$pubring->add($block);
$change++;
}
}
if ($change) {
write_keyring_file($pubring, $local_pubring);
}
}
sub write_keyring_file {
my ($keyring, $file) = @_;
open my $filehandle, ">", $file;
binmode $filehandle;
foreach($keyring->blocks) {
print $filehandle $_->save();
}
close $filehandle;
}
Show quoted text-----Original Message-----
From: Roland Huss via RT [mailto:bug-Crypt-OpenPGP@rt.cpan.org]
Sent: Saturday, March 05, 2011 10:13 AM
To: Xiaojun Tan
Subject: [rt.cpan.org #59781] Can't locate object method "save" via package "Crypt::OpenPGP::Trust"
<URL:
https://rt.cpan.org/Ticket/Display.html?id=59781 >
Same Problem here. Is there a simple workaround for this ?
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access or use by any other person to this internet email is not authorized and may be unlawful. If you are not the intended recipient, please delete or destroy this email. If you do not wish to receive future emails from this sender, please reply directly to this email requesting you be removed from any mailing list.