Kanishka has asked for the wisdom of the Perl Monks concerning the following question:
use LWP::Simple; use File::stat; print "CSE Stock Quote v1.1\n"; while ($company == ""){ FLAG: print "ENTER COMPANY CODE:"; chop ($company = <STDIN>); # Get the Company code from the command lin +e 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=<WORKFILE>) ne ""){ #Read file line by line $lineNo++; if ($ligne =~ /^$company$/ix){ #Match the Company code $CompanyLNo = $lineNo; #Get the line number of th +e company code print "$CompanyLNo\n"; open(WORKFILE2, "c:\\COMLIST.txt") or die "Can't open work F +ile: $!\n"; while(($comlist=<WORKFILE2>) ne ""){ if ($comlist =~ /$company/ix ){ @comname = split (/\,/, $comlist); } } } elsif($company =~ /\d\s/){ # avoids invalid company names with d +igits goto FLAG; } } close(WORKFILE); open FILE, "c:\\CSE.txt"; # re open CSE.txt @lines = (<FILE>)[$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"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to Get around Proxy
by tachyon (Chancellor) on Oct 27, 2003 at 07:48 UTC | |
|
Re: How to Get around Proxy
by inman (Curate) on Oct 27, 2003 at 14:56 UTC | |
by tachyon (Chancellor) on Oct 27, 2003 at 23:16 UTC | |
by Kanishka (Beadle) on Oct 30, 2003 at 04:09 UTC | |
|
Re: How to Get around Proxy
by Art_XIV (Hermit) on Oct 27, 2003 at 13:42 UTC |