#!/usr/local/bin/perl -w ############################################################################### # Mike Galsworthy's MEDSUM # # # # # # PROGRAM 3 : Getting web environment # # # # (credit to Oleg Khovayko for key Medline download parts of script) # # # # # ############################################################################### use Getopt::Long; my ($term); GetOptions ("query:s" => \$term); $term =~ s/~q~q~/\'/g; use LWP::Simple; $base = "http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?". "db=Pubmed". "&". "retmax=1". "&". "usehistory=y". "&". "term="; $signature = '&tool=medsum&email=mike_galsworthy@yahoo.co.uk'; $esearch = get($base . $term . $signature); $esearch =~ m|(\d+).*(\d+).*(\S+)|s; my $Count = $1; my $QueryKey = $2; my $WebEnv = $3; print "Count: $Count
"; print "QueryKey: $QueryKey
"; print "WebEnv: $WebEnv
"; open FILE, ">>log.txt" or die $!; print FILE "PR - $term ($Count) \r\n"; close FILE; if ($Count>0) { my $filename = $WebEnv . ".txt"; open FILE, ">>$filename" or die $!; print FILE "QRY - $term\r\n"; print FILE "CNT - $Count\r\n"; close FILE; }