use lib 'C:/Perl64/www-connotea-perl-0.1/lib/'; my $fn0="extracted-connotea-pubmedID-1.txt"; open (IN0, $fn0) or die "Can't open $fn0: $!\n"; open (FH, ">:utf8",'title_pmid_users_tags.txt'); ### # Modules Used ### use lib '../lib'; use WWW::Connotea; ### #Stage 0: Supply log-in credientals and autheticate ### my $currentURI; ### # Collect posts for the unique uris that is imported using file handler. ### my $c = WWW::Connotea->new( user => 'myusername', password => '........' ); $c->authenticate; ### dies if log-in credentials are incorrect while () { my $currentURI = $_; # for each unique URI chomp($currentURI); my @tags = $c->posts_for(uri =>"$currentURI"); # To get the posts for the unique uris die "No candidate related articles\n" unless @tags; print FH "$currentURI\n"; # foreach my $tag (@tags) { # To get the title directly from posts_for. It extracts the title from posts part in the XML file, the element . # print FH "Title: "; # my $zoo = $tag->title; # print FH $zoo; # print FH "\n"; # } # for my $tag (@tags) { # To get the title indirectly from posts_for using through bookmarks_for, just the element <dc:title> # print FH "title: "; # my $boo = $tag->bookmark(); # print FH $boo->title(); # print FH "\n"; # } foreach my $tag (@tags) { # To get the title indirectly from posts_for using through bookmarks_for and citations, the element <prism:title> print FH "title: "; my $boo = $tag->bookmark(); my $zoo = $boo->citation(); print FH $zoo->title(); print FH "\n"; } foreach my $tag (@tags) { print FH "PMID: "; my $boo = $tag->bookmark(); my $foo = $boo->citation(); for $bar($foo->identifiers()){ if ($bar =~ /PMID: (\d+)/) { print FH "$1\n"; } } } foreach my $tag (@tags) { print FH "User: "; my $bar = $tag->user; if (ref($bar) eq "ARRAY") { foreach my $q (@$bar){ print FH $q ,","; } } else { print FH $bar,","; } print FH "Tags: "; my $foo = $tag->tags; if (ref($foo) eq "ARRAY") { foreach my $p (@$foo){ print FH $p ,","; } } else { foreach my $p (@$foo) { print FH $foo,"\n"; } } print FH "\n"; } } close IN0; close FH;