in reply to Re: Help regarding regular expression
in thread Help regarding regular expression

Hi, Thanks a lot for the reply, the code seems to work but it is not giving any output while reading it from another file. Here is my full code:
use LWP::Simple; my $query = shift(@ARGV); die "Dead!!" unless (open(IN,">/home/vivek/Desktop/test12.txt")); $content = get("http://amigo.geneontology.org/cgi-bin/amigo/search.cgi +?query=$query;search_constraint=gp;action=query;view=query/"); die "Couldn’t get the website!" unless defined $content; print IN "$content"; while(IN) { my $line1; print "entered whileloop"; @line1 =~ "$1\n" if m/GO:(\d+)/; print "@line1\n"; close(IN); }
Can you please tell me where I am going wrong?

Replies are listed 'Best First'.
Re^3: Help regarding regular expression
by moritz (Cardinal) on Aug 06, 2009 at 10:55 UTC
    You open IN for writing, and later try to read from it - that won't work. Also reading from a file is done with <IN> (note the angle brackets).

    You also match against @line1 which you never initialized.