You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "tony@clearfox.com" <to...@clearfox.com> on 2005/08/10 18:57:32 UTC

mod_perl variables

 Hello Everyone,

 I have an issue that I am working on. I always ask questions that I 
have to a forum before writing the list just in case someone in the 
forum knows the answer. Usually I don't get any responses.

 I started this thread,

 http://www.tek-tips.com/viewthread.cfm?qid=1104388&page=1

 Will someone take a look and see if my last question can be answered. 
The first two posts will provide context for my situation. My handle is 
perl21

 I was following some advice from a fellow named Fish.

 In my last post in that thread I ask how to make my mod_perl script 
mess up the variable assignment of $html without using my or local

 Thank you,
 Tony


Re: mod_perl variables

Posted by Dan Brian <da...@brians.org>.
On Aug 10, 2005, at 11:07 AM, Boysenberry Payne wrote:

> This message contains information that is confidential
> and proprietary to Humaniteque and / or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.

Please ditch the signature, Boysenberry. Thank you.


Re: mod_perl variables

Posted by Perrin Harkins <pe...@elem.com>.
Tony,

Your questions about scoping are pretty common ones for beginning Perl
users.  May I suggest that you pick up a good book, like "Learning
Perl"?  That will go a long way towards clearing these things up for
you.

I'd also suggest reading this document:
http://perl.apache.org/docs/1.0/guide/porting.html

And I think you'll do better asking your questions on perl-specific
forums than on that one you tried before.  Take a look at perlmonks.org,
or one of the beginner lists shown here:
http://lists.cpan.org/

- Perrin


Re: mod_perl variables

Posted by "tony@clearfox.com" <to...@clearfox.com>.
Ok,

I went to google and did some more searching, this time just about the
my var.

I wrote this for an example of BAD use of $variable based on the
article I found.

I believe this demonstrates the coding in my website currently online.
lol, which is failing periodically.

---------------------------------------------------------------
my $i = 1;
my $variable;

if($i > 0)
{
   $variable = "Hello World!";
   print_it();
}

sub print_it()
{
   print "$variable<br>";
   $variable=1;
}


{
   my $variable = "True";
   print "$variable<br>";
}

print "$variable<br>";
---------------------------------------------------------------

When I run it for the first time I get

Hello World!
True
1

Every time after that I get

1
True
Hello World!

Until the process dies and it runs in a new thread.

I believe this is the demonstration of my problem right? I'm pretty
sure I understand now.

Thanks for the tips mate! I'll post this as my fix in the forum.
Tony

tony@clearfox.com wrote:

>
> Thank you for the response.
>
> I am sure going to start using strict.
>
> But one thing, why doesn't my example of NOT using strict, my, our, or 
> local ever fail.
>
> Shouldn't it confuse the $html var with the value of the $html var in 
> the parent file.
>
> Any ideas on what kind of an example will demonstrate to me the 
> variable problem I'm having in a small test program. I'm trying to 
> make a program that will show the effects of not using strict and 
> declaring the $vars. I want to be able to get it to mess up, and then 
> declare the $vars and see it work differently.
>
> I am trying to do this because I do not understand how the $vars are 
> treated differently when not declared.
>
> Thanks a lot!
> Tony
>
> Boysenberry Payne wrote:
>
>> It might be that your variable aren't scoped properly.
>> Try:
>>
>> use strict;
>>
>> my $variable
>> or
>> our $variable
>> to keep the variable scoped to the packages they're in.
>>
>>
>> Boysenberry
>>
>> This message contains information that is confidential
>> and proprietary to Humaniteque and / or its affiliates.
>> It is intended only for the recipient named and for
>> the express purpose(s) described therein.
>> Any other use is prohibited.
>>
>> http://www.habitatlife.com
>> The World's Best Site Builder
>> On Aug 10, 2005, at 11:57 AM, tony@clearfox.com wrote:
>>
>>>
>>> Hello Everyone,
>>>
>>> I have an issue that I am working on. I always ask questions that I 
>>> have to a forum before writing the list just in case someone in the 
>>> forum knows the answer. Usually I don't get any responses.
>>>
>>> I started this thread,
>>>
>>> http://www.tek-tips.com/viewthread.cfm?qid=1104388&page=1
>>>
>>> Will someone take a look and see if my last question can be 
>>> answered. The first two posts will provide context for my situation. 
>>> My handle is perl21
>>>
>>> I was following some advice from a fellow named Fish.
>>>
>>> In my last post in that thread I ask how to make my mod_perl script 
>>> mess up the variable assignment of $html without using my or local
>>>
>>> Thank you,
>>> Tony
>>>
>>>
>>>
>>
>
>




Re: mod_perl variables

Posted by "tony@clearfox.com" <to...@clearfox.com>.
 Thank you for the response.

 I am sure going to start using strict.

 But one thing, why doesn't my example of NOT using strict, my, our, or 
local ever fail.

 Shouldn't it confuse the $html var with the value of the $html var in 
the parent file.

 Any ideas on what kind of an example will demonstrate to me the 
variable problem I'm having in a small test program. I'm trying to make 
a program that will show the effects of not using strict and declaring 
the $vars. I want to be able to get it to mess up, and then declare the 
$vars and see it work differently.

 I am trying to do this because I do not understand how the $vars are 
treated differently when not declared.

 Thanks a lot!
 Tony

Boysenberry Payne wrote:

> It might be that your variable aren't scoped properly.
> Try:
>
> use strict;
>
> my $variable
> or
> our $variable
> to keep the variable scoped to the packages they're in.
>
>
> Boysenberry
>
> This message contains information that is confidential
> and proprietary to Humaniteque and / or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
>
> http://www.habitatlife.com
> The World's Best Site Builder
> On Aug 10, 2005, at 11:57 AM, tony@clearfox.com wrote:
>
>>
>> Hello Everyone,
>>
>> I have an issue that I am working on. I always ask questions that I 
>> have to a forum before writing the list just in case someone in the 
>> forum knows the answer. Usually I don't get any responses.
>>
>> I started this thread,
>>
>> http://www.tek-tips.com/viewthread.cfm?qid=1104388&page=1
>>
>> Will someone take a look and see if my last question can be answered. 
>> The first two posts will provide context for my situation. My handle 
>> is perl21
>>
>> I was following some advice from a fellow named Fish.
>>
>> In my last post in that thread I ask how to make my mod_perl script 
>> mess up the variable assignment of $html without using my or local
>>
>> Thank you,
>> Tony
>>
>>
>>
>



Re: mod_perl variables

Posted by Boysenberry Payne <bo...@humaniteque.com>.
It might be that your variable aren't scoped properly.
Try:

use strict;

my $variable
or
our $variable
to keep the variable scoped to the packages they're in.


Boysenberry

This message contains information that is confidential
and proprietary to Humaniteque and / or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.

http://www.habitatlife.com
The World's Best Site Builder
On Aug 10, 2005, at 11:57 AM, tony@clearfox.com wrote:

>
> Hello Everyone,
>
> I have an issue that I am working on. I always ask questions that I 
> have to a forum before writing the list just in case someone in the 
> forum knows the answer. Usually I don't get any responses.
>
> I started this thread,
>
> http://www.tek-tips.com/viewthread.cfm?qid=1104388&page=1
>
> Will someone take a look and see if my last question can be answered. 
> The first two posts will provide context for my situation. My handle 
> is perl21
>
> I was following some advice from a fellow named Fish.
>
> In my last post in that thread I ask how to make my mod_perl script 
> mess up the variable assignment of $html without using my or local
>
> Thank you,
> Tony
>
>
>