Date: Fri, 15 Sep 2000 16:34:41 +0100 From: Ben Smithurst <ben@FreeBSD.org> To: Mark Ovens <marko@freebsd.org> Cc: chat@freebsd.org Subject: Re: perl(1) variable declarations Message-ID: <20000915163441.A56185@strontium.scientia.demon.co.uk> In-Reply-To: <20000915130220.C257@parish> References: <20000915130220.C257@parish>
next in thread | previous in thread | raw e-mail | index | archive | help
Mark Ovens wrote: > Is > > use vars qw/ $foo $bar /; > > the same as > > my $foo; > my $bar; > > when used for global variables? I think "my" variables won't work if you want to set them from another file, but I don't remember exactly. e.g. ==== main ==== my ($foo, $bar); require "globals.pl"; print "foo=$foo bar=$bar\n"; ============== ==== globals.pl ==== $foo = 1; $bar = "sheep"; ==================== I don't think this will work, but I think it will if you use "use vars" instead. That's the only difference I recall coming across, so I always use "my" except in cases like the above. -- Ben Smithurst / ben@FreeBSD.org / PGP: 0x99392F7D To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000915163441.A56185>