Those are some really good questions. Fortunately, they do have answers...
To open a pipe with the 3-argument form of "open", you want to use '|-' or '-|' to indicate the mode. In your case, I think this should do the trick...
open my $LSTAC, '-|', "$lstac -m"
See `perldoc -f open` and `perldoc perlopentut` for all the gory details.
It is true that you can't make $_ lexical with "my". The best approach is to use a named iterator, instead of defaulting to $_ (also known as the "topic" or "scratch" variable). That way, the reader has a better idea what is actually in the iterator. For example...
foreach my $person (@population){ print $person }
If you absolutely insist on using $_ as your iterator, then you don't need to declare it at all...
foreach (@population) { print }
But using a named iterator (which is also recomended by Conway) will make your code much more readable.
Hope that helps. Happy New Year!
-Jeff
(9)
]
