summaryrefslogtreecommitdiff
path: root/rhimport.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2012-01-20 22:54:46 (GMT)
committerChristian Pointner <equinox@helsinki.at>2012-01-20 22:54:46 (GMT)
commit5c15154a15840173ca8167bb0bbb3db32290ce41 (patch)
treeb2f59ab1f9d0cc4f1820fdcf3eb13d22dc3aa4b9 /rhimport.pm
parentfed2da097618da584b71637b50204666fe304ee1 (diff)
moved pv add note to rhimport modul
Diffstat (limited to 'rhimport.pm')
-rw-r--r--rhimport.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/rhimport.pm b/rhimport.pm
index d44c34b..6e125d2 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -327,4 +327,31 @@ sub delete_file
return 1;
}
+sub pv_add_note
+{
+ my $title = shift;
+ my $text = shift;
+ my @script = @_;
+
+ my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle );
+ $writer->autoflush(1);
+ local $SIG{CHLD} = 'DEFAULT';
+ my $pid = open3($writer, $reader, $error, @script);
+ binmode($reader, ":utf8");
+ binmode($writer, ":utf8");
+ binmode($error, ":utf8");
+ print $writer $title . "\n" . $text;
+ close $writer;
+ waitpid $pid, 0;
+ if ( $? >> 8 ) {
+ print "\n\nPV: adding note returned non-zero value\n";
+ print "STDERR:\n" . join('', <$error>) . "\n";
+ print "STDOUT:\n" . join('', <$reader>) . "\n";
+ print "Ignoring failed headline import!\n";
+ } else {
+ print join('', <$reader>) . "\n";
+ print join('', <$error>) . "\n";
+ }
+}
+
1;