although some relationships exist between stocks, a lot depends on decisions made by large companies and governments, e.g. start a war and see the oil prices and gold go up. as you don't have this sort of data in computational form, it will not be considerred by your formulae.
Besides all the above (unknown) factors, statistical analysis is confined to the realm of equations/formulae, which are not the best models for the (sometimes subtle) movements of stocks.
A lot of effort has recently gone into picking market trends by using neural networks. there are already simple neural network perl modules around, but I haven't seen any such module specifically sculpted for trading analysis. Instead, there exists a number of commercially written ($$$) applications that do exactly the same thing, and display the result in fancy 3D graphs. If you just want to have fun analysing/guessing market trends and playing with the maths, then this would be the way to go....If you're serious about making money, just follow company/government decisions and the resulting market impact
the hardest line to type correctly is: stty erase ^H