I'm sure someone will correct me if I'm wrong...
But, variables in the initial section (ie outside of a function) in the main
package will stay in scope all the time.  This means that it will retain the
value from a previous request- which might be giving you these problems.

As Perrin Harkins wrote, there are various solutions documented in the FAQ.
You need to read these and follow one of the methods.

> Read this:
>
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#my___
Scoped_Variable_in_Nested_Subroutines
> 
> - Perrin


Personally I use the CGI::Application framework, which I find gives a really
nice framework to develop applications in.  Each application is a package,
and each "run mode"  is a sub which means you don't get any of these scope
problems.

Good luck,
David.

Mae’r neges e-bost hon ac unrhyw ffeiliau sydd ynghlwm wrthi yn gwbl gyfrinachol ac 
wedi’u bwriadu at sylw yr unigolyn neu’r endid y maent wedi eu cyfeirio ato yn unig. 
Gallant gynnwys gwybodaeth sy’n freintiedig yn gyfreithiol a/neu’n gyfrinachol ac os 
nad chi yw’r sawl y cyfeiriwyd y neges ato, yna peidiwch â chopio, dosbarthu na 
chymryd unrhyw gamau o ganlyniad a gan ddibynnu arni. Os ydych wedi derbyn y neges 
e-bost hon ar gam, a wnewch chi ein hysbysu o hyn cyn gynted â phosib a’i dileu os 
gwelwch yn dda. Barn neu safbwyntiau’r awdur yw’r rhai a fynegir yn y neges e-bost hon 
ac/neu’n unrhyw atodiadau ac nid ydynt yn adlewyrchu o anghenraid barn neu safbwyntiau 
S4C.

This e-mail message and any files attached are strictly confidential and intended 
solely for the attention of the person or entity to whom they are addressed. They may 
contain legally privileged and/or confidential information and if you are not the 
addressee, you should not copy, distribute nor take any action in reliance on them. If 
you have received this e-mail message in error, please notify us as soon as possible 
and delete it. The views and opinions expressed in this e-mail message and any 
attachments are the author’s own and they do not reflect necessarily the views and 
opinions of S4C.

Reply via email to