Professional Web Applications Themes

The Proper way to define a global variable. - PERL Beginners

Hello. I am using variables that are local in my scripts by doing the my $variable_name technique. Can someone tell me if there is an official way to define a global variable?...

  1. #1

    Default The Proper way to define a global variable.

    Hello. I am using variables that are local in my scripts by doing the my $variable_name technique.

    Can someone tell me if there is an official way to define a global variable?


    Jason Guest

  2. #2

    Default Re: The Proper way to define a global variable.

    Jason Corbett wrote: 

    use vars qw($global1 $global2);

    or

    our ($global1, $global2);

    The latter cannot be used in Perl versions previous than 5.6.0. Note
    that the two methods do not do exactly the same thing; see the docs:

    perldoc vars
    perldoc -f our

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  3. #3

    Default Re: The Proper way to define a global variable.

    Jason Corbett wrote: 

    Perl doesn't really have "global" variables (like BASIC does), except
    for some of the special variables listed in perlvar.pod. Perl's
    variables are either package or lexically scoped.


    John
    --
    use Perl;
    program
    fulfillment
    John Guest

  4. #4

    Default Re: The Proper way to define a global variable.

     
    >
    > Perl doesn't really have "global" variables (like BASIC does), except
    > for some of the special variables listed in perlvar.pod. Perl's
    > variables are either package or lexically scoped.[/ref]

    Can you not use our?


    Chris Guest

Similar Threads

  1. How to define a Global Histroy Manage
    By personaex in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: January 25th, 07:42 AM
  2. how to define ths variable
    By Romain in forum PERL Beginners
    Replies: 2
    Last Post: April 14th, 11:38 PM
  3. define variable problem
    By grover970 in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 20th, 03:19 PM
  4. define global variables through a repeat loop
    By kiaoraFiona webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 7
    Last Post: September 26th, 09:03 AM
  5. Global pound define?
    By Andrew in forum ASP.NET General
    Replies: 1
    Last Post: July 15th, 12:57 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139