Difference between my() and $var = false

Discussion in 'Perl Misc' started by Jason C, Dec 14, 2011.

  1. Jason C

    Jason C Guest

    Is there a technical difference between these two?

    my($var);
    $var = false;
    Jason C, Dec 14, 2011
    #1
    1. Advertising

  2. Jason C

    Jason C Guest

    On Tuesday, December 13, 2011 11:52:27 PM UTC-5, Jason C wrote:
    > Is there a technical difference between these two?
    >
    > my($var);
    > $var = false;


    Or, well, I guess I should say $var = undef, not $var = false. Sorry, I haven't really programmed in Perl in awhile.
    Jason C, Dec 14, 2011
    #2
    1. Advertising

  3. Jason C <> writes:

    > Is there a technical difference between these two?
    >
    > my($var);
    > $var = false;


    The first declares a lexically scoped variable.

    The second declares a global variable (and will die on 'use strict').

    Mart

    --
    "We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.
    Mart van de Wege, Dec 14, 2011
    #3
  4. Jason C <> wrote:
    >Is there a technical difference between these two?
    >
    >my($var);
    >$var = false;


    Hmmmm, do they have anything in common?

    jue
    Jürgen Exner, Dec 14, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thomson
    Replies:
    10
    Views:
    2,492
    Eliyahu Goldin
    Jun 20, 2005
  2. thomson
    Replies:
    0
    Views:
    379
    thomson
    Jun 20, 2005
  3. daniele.g
    Replies:
    4
    Views:
    478
    Joe Pfeiffer
    Jul 15, 2011
  4. Shea Martin

    difference between @var and self.var

    Shea Martin, Jun 21, 2006, in forum: Ruby
    Replies:
    2
    Views:
    150
    Shea Martin
    Jun 22, 2006
  5. Replies:
    17
    Views:
    190
Loading...

Share This Page