reraised on
Stack Overflow.
Fishmonger has given you great advice, you should use it.
Indeed his and your advices are very valuable but I have gone a long way in this application I don't wanna change the framework like using Template Toolkit at this point, I do not wanna do everything all over again, but I am making notes of everything and saving links etc for my next project, as you must have realized this is my very first project !! I don't want to pass around $user variable from script to script as there are so many scripts in my application
I think I remember seeing a snippet of your code where you used CGI::Session to create a user session. This is where you could store data such as user. Pass this data to your HTML / javascript whenever you need it, in the same manner as when you pass the current page number to your pagination plugin.
Yes, you're right I am using it in my application but that java script is providing a template for my project and is used globally throughout the application, there are couple of issues with using CGI::Session for the purpose like I don't know how to pass variables stored in CGI Session to JS script or how to make JS script to read the value from CGI Session, and if I just use CGI Session to retrieve $user value and display it on the page using perl then given the framework provided by the JS script I cannot place it exactly where I want to do it, that is why I am sticking with that JS script, its way easier for me to use Perl and get helped as there are so many Gurus and Monks like you to always help me out. As advised previously, you should break your application into functions, or atleast code that you need to regularly repeat, and put into an external file accessible by all your scripts. One of these functions could fetch user data and be called in each of your scripts i.e.
my $user_data = fetch_user_data( @args ). We won't delve into object orientated Perl just yet!
With this approach, again the problem is of placement/positioning of that information on the webpage, if I go for something outside of that JS script framework I cannot place where it should be, I have described that in one of my above comments, see the picture attached. Thanks much !!Terry.