Results 1 to 4 of 4

Thread: PERL non-private variable

  1. #1

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332

    PERL non-private variable

    i knw if i want a private variable i can write:
    Code:
    my $cat = "cat";
    but what if i want a variable to be availabel through-out a script?
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Scope it a "file level" (right at the top of your script, before any functions, etc) which puts it in the default "main" package. Else look into the Perl doc about the our keyword.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332
    thanks, but while looking at the "our" scope i found the "local" scope... can anyone telling the difference b/c the documentation is unclear on this point

    ps: anyone know any good perl tutorials\books\references on-line?

    i've got the ActiveState documentation that came with my perl interpreter and the "picking up PERL" pdf which is quite basic to say the least...
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Changes are you want to stick with "my" unless you're working with your own packages. Basically, local is used within a function to decalre a variable with the same name as a global one with the function, but functions called from within the function don't get the global variable. I think local will probably be obsoleted sometime.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width