Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > ultimate n00b question re: my / our

Reply
Thread Tools

ultimate n00b question re: my / our

 
 
Koncept
Guest
Posts: n/a
 
      12-05-2003

I hope this is not too silly...

What is the difference between setting a var with my or our? When would
I know to distingish between the two? Also, is this necessary to always
define when setting a var?

Thanks!

--
Koncept <<
"Contrary to popular belief, the most dangerous animal is not the lion or
tiger or even the elephant. The most dangerous animal is a shark riding
on an elephant, just trampling and eating everything they see." - Jack Handey
 
Reply With Quote
 
 
 
 
Nick Santos
Guest
Posts: n/a
 
      12-06-2003

"Koncept" <> wrote in message
news:051220031452137698%...
>
> I hope this is not too silly...
>
> What is the difference between setting a var with my or our? When would
> I know to distingish between the two? Also, is this necessary to always
> define when setting a var?
>
> Thanks!



It is not necessary to define your variables as mine or our. You can simple
declare them like so

$foo;
#or
$foo=12;

the first of which isn't necessary. One of the great things about perl is
that scalar variables are pretty much all your basic types in one, so you
don't even NEED to declare them at all, you can just start using them. As
for the case of my and our, I've seen people use my because it defines that
it comes from a local source(though I may be wrong). I think the programmers
that put my are using it as much for their knowledge as for the compilers. I
personally have never heard of using an "our" defiinition." That'll have to
come from someone else's knowledge
-Nick


 
Reply With Quote
 
 
 
 
Koncept
Guest
Posts: n/a
 
      12-06-2003
In article <EGfAb.36369$_M.167792@attbi_s54>, Nick Santos
<> wrote:

> As
> for the case of my and our, I've seen people use my because it defines that
> it comes from a local source(though I may be wrong). I think the programmers
> that put my are using it as much for their knowledge as for the compilers.


I figured this much. Thanks for your help.

As for "our" this is what I found:

"An our declares the listed variables to be valid globals within the
enclosing block, file, or eval. That is, it has the same scoping rules
as a ``my'' declaration, but does not create a local variable. If more
than one value is listed, the list must be placed in parentheses. The
our declaration has no semantic effect unless ``use strict vars'' is in
effect, in which case it lets you use the declared global variable
without qualifying it with a package name."

http://aspn.activestate.com/ASPN/doc...erlfunc.html#i
tem_our

--
Koncept <<
"Contrary to popular belief, the most dangerous animal is not the lion or
tiger or even the elephant. The most dangerous animal is a shark riding
on an elephant, just trampling and eating everything they see." - Jack Handey
 
Reply With Quote
 
Nick Santos
Guest
Posts: n/a
 
      12-06-2003

"Koncept" <> wrote in message
news:061220031455130889%...
> In article <EGfAb.36369$_M.167792@attbi_s54>, Nick Santos
> <> wrote:
>
> > As
> > for the case of my and our, I've seen people use my because it defines

that
> > it comes from a local source(though I may be wrong). I think the

programmers
> > that put my are using it as much for their knowledge as for the

compilers.
>
> I figured this much. Thanks for your help.
>
> As for "our" this is what I found:
>
> "An our declares the listed variables to be valid globals within the
> enclosing block, file, or eval. That is, it has the same scoping rules
> as a ``my'' declaration, but does not create a local variable. If more
> than one value is listed, the list must be placed in parentheses. The
> our declaration has no semantic effect unless ``use strict vars'' is in
> effect, in which case it lets you use the declared global variable
> without qualifying it with a package name."
>
> http://aspn.activestate.com/ASPN/doc...erlfunc.html#i
> tem_our
>
> --
> Koncept


Cool, looks like I learned as much from your post as you did. Thanks
-Nick


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I have 2 IP addresses on our internal interface on our cisco pix firewall bgamblin@spvg.com Cisco 1 09-08-2005 08:54 PM
How do we stamp our names onto our photos? Kim Digital Photography 6 01-06-2005 06:12 AM
New Releases: Ultimate Rambo, Ultimate Oliver Stone & More 2 packs: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 0 09-10-2004 04:34 AM
n00b Question re: MSDE SQL 2000 Set-up newgenre ASP .Net 2 04-19-2004 06:16 PM
Where do we get our MCDST symbols to put in our outlook signature? sb20056 MCDST 1 04-09-2004 09:40 PM



Advertisments