1. Put a my $yesterday; outside of the if clause. Then, it's just $yesterday = &read_benchmark();. This is creating a global variable. Acceptable, but not very scalable.
That would issue a compile time error. You need to tell you're going to use the global first, with our or use vars. This can be avoided by just using my: the lexical scopes lasts till the end of the file, so the subs can access it. This behaviour is often unintended, and the results are indeed not very scalable. Because of that, I advise the author of the root node in this thread to put main code after the subs, to get them out of lexical scope.
Update - It would not issue a compile time error, because it would not be a global at all. Instead, it'd be a lexical variable that lasts until the end of the file. This makes most of my original post untrue. However, it is imho still a bad idea to use globally used lexicals.
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
In reply to Re: Re: Problem Declaring Variable
by Juerd
in thread Problem Declaring Variable
by PrimeLord
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |