http://www.perlmonks.org?node_id=52044

After browsing through a couple of other people's CUFP
i've found that this LWP::Simple type thing isn't
actually to original but at the same time, i'm pretty
proud of it
both because it's short and reasonably elegant (but TSE
specific, i don't know how easy it is to generalize)

I wrote it for my dad cause i think it will save hime
HOURS of time looking up stuff on the internet and give
hime the extra time he needs to do the analysis

he didn't want to use an online profile system because
he dosen't want other people to know what his stock
picks look like :)

one thing i would like help with is compiling the code
into an EXE for windows. I've looked at the thread
Compiling Code? and others but cannot make perl2exe OR
perlcc work properly (problems with either the use
LWP::Simple, or perlCC working at ALL)

i'm at the point where i'd just about rather be 'given
the fish' (if you get the reference)

here's the code for those who're interesed . . . note
the REGEX instead of HTML::Parser (yes Dave i knew
you'd be upset with that but ends and means
donchaknow ;)
the regex is actually code re-use i think it was the
strip html tags thread

#!f:\perl\bin\perl #note that strict is commented out, [jjhorner] i'm sure #you'll love that ;) #use strict; use LWP::Simple; my ($webpage,$TickerSymbol,$value,$junk,@wpArray,$counter,$results,%re +sults); my @fields = ("TickerSymbol","LastTraded","NetChange","Open","Low","Hi +gh","Volume","LastBidSize","LastBidPrice","LastAskSize","LastAskPrice +","#ofSharesOutstanding","Rolling52WeekHigh","Rolling52WeekLow","Quot +edMarketValue","DividendTimingIndicator","Earnings/Share(trailing12mo +nths)","DividendYield"); # ts file is a one-per line list of the TSE ticker symbols # that the user wants in their output # the file is terminated on each line with a comma # to keep the ticker symbol clean open tsFILE, "<ts.txt" or die "Couldn't open: $!"; foreach $value (@fields) { print "$value\t" } print "\n"; while (<tsFILE>) { ($TickerSymbol,$junk) = split/,/; $webpage= get "http://www.tse.com/cgi-bin/clan_quote?securityType= +TSE-EQUITY&qoteQuery=" . $TickerSymbol; $webpage =~ s/&nbsp;//g; $webpage =~ s/<[^>]*?>//g; $webpage =~ s/ //g; @wpArray = split (/\n/,$webpage); $counter = 0; foreach $value (@wpArray) { $results{$value} = $wpArray[++$counter]; } $results{"TickerSymbol"} = $TickerSymbol; foreach my $key (@fields) { print "$results{$key}\t"; } print "\n"; }

anyways, i'm very happy with it as i started writing it
last night and it was a lot easier than i though it
would be.

If anyone can turn it into a windows98 EXE for me i
would be eternally in your debt . . . as i said, it's
intended as a gift for my father and has to be
standalone
it could bloat from 30K to 1.5 Megs and i wouldn't mind
so long as it worked as an EXE

Replies are listed 'Best First'.
Re: Stock Market Tracker (TSE)
by a (Friar) on Jan 16, 2001 at 08:45 UTC
    Why an 'exe'? Why not pare perl down to the bare needed libs plus LWP::Simple and give him a batch file to run it all, w/ everything unpacked in one dir or something. He must have pkunzip/netzip/winzip somewhere or make one of those self extractors out of it. Best part is, as you fix up your code, you can then just send him the updates ... or teach him perl. The best/easiest: the activestate install, for example, is pretty swift and clean. Run that, add your script to the desktop ...

    a

      That is a GREAT idea. !!!!
      so the question i've got to ask now is:
      how small can i make PERL?

      and, of course, what can i/can't i cut out?

Re: Stock Market Tracker (TSE)
by myocom (Deacon) on Jan 16, 2001 at 00:50 UTC

    You can turn this into an EXE by running Perl2EXE on it...

    UPDATE: That'll teach me to skim posts...

    With Perl2EXE it should just be a matter of running perl2exe stock.pl (assuming stock.pl is the name of your script). Bear in mind that if the URL ever changes, you'll need to change the source code and recompile it. You may want to put the URL into your config file as well rather than having it hardcoded.

Re: Stock Market Tracker (TSE)
by wee (Scribe) on Jan 25, 2001 at 06:39 UTC
    I tried to make an EXE for you, but my version of Perl is a little messed up on this machine (I don't have many Win32 machines, so...). I did get the script to compile into an EXE, though. You need to add the path to the libs directory ('set PATH=%PATH%;C:\PERL\SITE\LIB' in my case). Then you need to do something scary: you need to comment out the 'strict' pragma from HTTP:Status.pm (at line 6) and LWP::Simple.pm (at line 147). For some reason, it wouldn't compile otherwise. Oh yeah, those line numbers might be a little different for you, but you get the idea.

    That's about all there is to it. If I had a cleaner environment, I'd have an EXE for you, but this box is a little whacked. Good luck to ya...

    -Bill