?
Solved

perl global array initialization

Posted on 2003-02-18
3
Medium Priority
?
1,364 Views
Last Modified: 2006-11-17
In one of my perl scripts i have a global array @pf_info
In one of my functions - i build this array. Now say it has the @pf_info has 2 elements.

In the same code, in my next function i empty the array saying
@main::pf_info = ();
and try and build the array with some other variables. But when i print the array, i see that the pf_info has the older 2 elements + the new list.

Is the way i am initializing incorrect?

Pleas bear with me is u find my problem silly. But please give me some suggestion...

Regards,
Lakshmi
0
Comment
Question by:lakshminair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
blinkie23 earned 200 total points
ID: 7979916
in theory your description seems like it would work.  but i haven't actually seen the code.  your description describes what you want to happen while the code may have a slightly different interpretation.

one of your functions may be out of scope.  if you use "my" or "local" or "use strict" anywhere, or frequently use package names like "main" and other times not.. you could have scope problems somewhere.  essentially this would cause a change to take place locally, but not globally.

this is just a hunch.  also, try using "undef @main::pf_info" instead of "@main::pf_info = ()" and see if this helps.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9691627
Nothing has happened on this question in over 8 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by blinkie23.

Please post any comments here within the next seven days. Moderators check comments here before acting on the recommendation. Experts: silence will likely be taken as assent.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question