Syntactic Confectionery Delight | |
PerlMonks |
Re: Re: Re-calling in a list of variables into different .pl'sby Lori713 (Pilgrim) |
on Feb 06, 2004 at 15:17 UTC ( [id://327095]=note: print w/replies, xml ) | Need Help?? |
I've no idea what you want to do. &call_variables doesn't expose any variables to the outside - all it does is return values. Exactly my problem. I'll try to further (and hopefully better) explain what I want to do. I have a section of code that I'm using in several programs. The section looks exactly like what is inside the sub I described above (no variation nor different values assigned, etc). If it were possible, I would copy and paste that section into every program it needs to go into. Of course, while you're running programs you can't very well say, "Hold on, I need to copy and paste that text into the program before you run it!" I'm using the same 25 lines of code (get the param, split the array, assign the variables their $array values), so I was looking for a way to somehow automagically insert that section each time. I read the POD about Exporter. If I understand Abigail-II and arden correctly, Exporter will let me put my repeating section of code in a .pm package that I use or require. However, it seems like I'll still need to declare all the variables (my $one, my $two) near the beginning of each program that will be calling the sub. Do I have that right? So, I would end up with something like: This would be in the myVars.pm file: That means that the above new stuff would be the same as if I had typed in this section into a program instead of calling the sub - is that right?
In the meantime, I'll be reading up on use and require to better understand the difference.
Lori
In Section
Seekers of Perl Wisdom
|
|