Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re-calling in a list of variables into different .pl'sby Lori713 (Pilgrim) |
on Feb 06, 2004 at 14:10 UTC ( [id://327068]=perlquestion: print w/replies, xml ) | Need Help?? |
Lori713 has asked for the wisdom of the Perl Monks concerning the following question:
Suppose I have five variables ($one, $two, $three, $four and $five) that I use in several different programs (I actually have about 25 variables that I'm tracking). I'd like to figure out a way to call these in each time I run certain programs while I'm doing the use strict thing so I don't have to type them in over and over (plus their values are being set by a split on an array and I occassionally need to change the order of things, so it's a PITA to change the index numbers on every instance). I was thinking maybe a using a subroutine to call them in, but I can't figure out how to do that. Here's what I'm thinking:
This would be the sub: BTW, it would be nice to figure out a way to iterate over the index numbers, but I think I can figure that out later. Would it be better to create a small .txt file, read that in, and then try to get it to spit it out each time I run &call_variables? Should I create a little package that contains all these? I'm sure there's severals ways to do this. I read the section on subroutines in the Llama book but nothing seem to address the concept of just "reading in" lines into the main program and returning those values to the program (because it only returns the last value from what I understand, plus it doesn't allow me to just use the variables without "my"ing them again). Thanks for any light you can shed! Lori
Back to
Seekers of Perl Wisdom
|
|