Hi, I have been searching the web for some advice on how to have persistent variables or how can we access a variable defined with our in a perl program file(.pl or main package one can say) across other modules.
I have read so many posts and articles but one or the other explains how to share global variables among packages( using exporter most of the time and somewhere through perl aliasing feature), but no one encounters a scenario in which a global variable from the main::package or say main.pl is required in some module.
To explain it or be specific in explaining my particular scenario let say:
#!/usr/bin/perl # main.pl use warnings; use strict; require "functions.pl"; our ($glbA, $glbB); $glbA = "Main_GlobalA"; $glbB = "Main_GlobalB"; procedureA(); procedureB();
I have been stuck on this issue for a week now. Any sort of suggestion or correction in my approach would be of great help! Waiting for a prompt reply#!usr/bin/perl # functions.pl use warnings; use strict; sub procedureA { print $glbA; } sub procedureB { print $glbB; } 1;
In reply to How to access main package global vars in modules by codewalker82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |