473,606 Members | 2,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the error:: Variables will not stay shared

25 New Member
Hi,

I am sending the values from one method to another method to get the values from xml file based on the inputs.
I am getting the error like::
Variable "$collType" will not stay shared
Variable "$collState " will not stay shared at line 77.

please see the below code and help me out.


Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl -w
  2. use XML::Parser;
  3.  
  4.  my @element_stack;                # remember which elements are open
  5.  my %hash;
  6.  
  7.  main();
  8.  
  9. sub main {
  10.     my $collType="A";
  11.     my $collState="AE";
  12.     my $custName="Robin";
  13.  
  14.     parseFile($collType, $collState, $custName);
  15.  
  16.     my $team = $hash{"Default"};;
  17.     print "size of hash:  " . keys( %hash ) . ".\n";
  18.  
  19.     my $el=$custName;
  20.     my @arr;
  21.     @arr = split(//,$el);
  22.     foreach(keys %hash) 
  23.     {
  24.  
  25.         if($_ =~ /$arr[0]/)
  26.         {
  27.              $team = $hash{$_};
  28.             print "$_ team is $hash{$_}";
  29.  
  30.         }
  31.         last;
  32.  
  33.     }
  34.     print "Team is $team \n";
  35. }
  36.  
  37.  sub parseFile {
  38.  my($collType, $collState, $custName) = @_;
  39.  
  40.  
  41. # initialize the parser
  42. my $parser = XML::Parser->new( Handlers => 
  43.                                      {
  44.                                       Start=>\&handle_start,
  45.                                       End=>\&handle_end,
  46.                                      });
  47. $parser->parsefile("../../extract/unicar/state.team.group.xml" );
  48.  
  49.  
  50. # process a start-of-element event: print message about element
  51.  
  52. sub handle_start {
  53.     my( $expat, $element, %attrs ) = @_;
  54.  
  55.     # ask the expat object about our position
  56.     my $line = $expat->current_line;
  57.  
  58.  
  59.  
  60.     # remember this element and its starting position by pushing a
  61.     # little hash onto the element stack
  62.     push( @element_stack, { element=>$element, line=>$line });
  63.     if($element eq "StateTeamGroup" || $element eq "StateTeam" || $element eq "State"){
  64.  
  65.         if( %attrs ) {
  66.  
  67.         if($attrs{"CollType"} eq $collType and $attrs{"State"} eq $collState)## getting the error here
  68.          print "$collType and $collState *********\n";
  69.             $hash{  $attrs{Letters}  } = $attrs{Team}
  70.         }
  71.         }
  72.  
  73.      }        
  74.  
  75.  
  76. }
  77.  
  78.  
  79. # process an end-of-element event
  80. #
  81. sub handle_end {
  82.     my( $expat, $element ) = @_;
  83.  
  84.  
  85. }
  86.  
  87. }
  88.  
And my xml file will be like this:

Expand|Select|Wrap|Line Numbers
  1. <StateTeamGroup>
  2.   <StateTeam>
  3.  
  4.      <State CollType="A" Comment="Military addresses" Letters="Default" State="AE" Team="TEAM3"/>
  5. <State CollType="A" Comment="Military addresses" Letters="ABCD" State="AE" Team="TEAM2"/>
  6.  
Oct 15 '07 #1
1 3969
KevinADC
4,059 Recognized Expert Specialist
That is not an error, it is a warning. Does the script work?
Oct 15 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5021
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
3
2041
by: sarmin kho | last post by:
Hi Pythoners, i have been using a lot of global variables in the python script i am working on. the global variables are shared and used by all various 'definitions' : def name (): global all globs... ..... my question is: 'is it safe using global variables in term of its execution time?
6
4732
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
6
1657
by: Alixx Skevington | last post by:
OK why does the following code work in a Windows form with a crystal report viewer but not in a webform. I get the usual CrystalReports.EngineLogONException logon Failed when this is called in aspx. Any help will be very much apprecaited Alixx This is the code in the calling aspx Page
11
1333
by: Matt Mercer | last post by:
Hi, I have a simple question about vb .net variables. There is so much info on variables out there I had trouble finding exactly what I am looking for. Here is the question: When I use a variable (for example Dim strWhatever As String) in server code, is a new instance of the variable create for each user who visits the page? I know I need session variables for user specific information across multiple pages (there are other ways but...
2
1795
by: Oenone | last post by:
I'm upgrading a DLL from VB6 to VB.NET. The DLL gets called from an ASP.NET web application. In the VB6 code there is a module-level object which stores the context about what the user is doing during each page request. This object is initialised at the start of each request and populated with various data retrieved from the URL, and is then repeatedly queried throughout the rest of the page generation. Am I right in thinking that...
9
3179
by: Randy | last post by:
Hello, I'm having a strange problem. I've got a .NET web app which uses Session variables. Sometime, not all the time, they get cross threaded...that is...one user will have another user's Session variable(s) data assigned to them. I can't figure out why. I've read that other people are having this problem too but I haven't found a resolution yet. Can someone please tell me how I might go about fixing this? Thanks
669
25788
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
2
13669
by: ronchese | last post by:
I'm noticing this since I started developing a website project: my session variables are getting empty! I did a real easy test, and I checked my session variable is getting empty!! What is happening? For example (VS2005, IE6/7, running in filesystem): - In the Page_load of page1.aspx: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Throw New Exception("Error is thrown") End Sub
0
7962
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8443
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6792
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5971
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3945
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1309
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.