use LWP::Simple; use File::stat; print "CSE Stock Quote v1.1\n"; while ($company == ""){ FLAG: print "ENTER COMPANY CODE:"; chop ($company = ); # Get the Company code from the command line if ($company =~ /EXIT/i){ last; #exit the program when typed 'EXIT' } else{ $reponse = get("http://203.115.0.6/servlet/RealIndicesServlet"); #get the information from this URL open(OUTFILE, ">c:\\CSE.txt") or die "Can't open out File: $!\n"; # Make and OPen a file print OUTFILE $reponse; # SAve information In a file close OUTFILE; open(WORKFILE, "c:\\CSE.txt") or die "Can't open work File: $!\n"; #Re open CSE.txt for get information $lineNo = 0; while(($ligne=) ne ""){ #Read file line by line $lineNo++; if ($ligne =~ /^$company$/ix){ #Match the Company code $CompanyLNo = $lineNo; #Get the line number of the company code print "$CompanyLNo\n"; open(WORKFILE2, "c:\\COMLIST.txt") or die "Can't open work File: $!\n"; while(($comlist=) ne ""){ if ($comlist =~ /$company/ix ){ @comname = split (/\,/, $comlist); } } } elsif($company =~ /\d\s/){ # avoids invalid company names with digits goto FLAG; } } close(WORKFILE); open FILE, "c:\\CSE.txt"; # re open CSE.txt @lines = ()[$CompanyLNo+1..$CompanyLNo+3]; # get data in 2nd to 4th lines which preceeds the company code line close (FILE); $filepath = "c:\\CSE.txt"; stat($filepath); unlink $filepath or die "Couldn't delete $filepath: $!"; if (@comname[1] =~ /NULL/){ print "STOCK PRICE OF Company Name N/A \n"; } else{ print ("STOCK PRICE OF ", @comname[1]); } print ("Now Price Rs: ", $NowPrice = @lines[0]); if ($NowPrice =~ /\+/){ print ("Price UP By Rs: ", $PriceChange = @lines[1]); } elsif ($NowPrice =~ /\-/){ print ("Price DOWN By Rs: ", $PriceChange = @lines[1]); } elsif ($NowPrice =~ /\~/){ print ("Price UNCHANGED By Rs: ", $PriceChange = @lines[1]); } print ("Quantity Traded ", $Quantity = @lines[2],"\n"); } }