?
Solved

perl global array initialization

Posted on 2003-02-18
3
Medium Priority
?
1,370 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
2 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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
Suggested Courses

569 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