From owner-freebsd-chat Fri Sep 15 9:15:22 2000 Delivered-To: freebsd-chat@freebsd.org Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by hub.freebsd.org (Postfix) with ESMTP id D625F37B422; Fri, 15 Sep 2000 09:15:19 -0700 (PDT) Received: from parish ([62.253.88.147]) by mta02-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000915171412.FELW23965.mta02-svc.ntlworld.com@parish>; Fri, 15 Sep 2000 17:14:12 +0000 Received: (from mark@localhost) by parish (8.11.0/8.11.0) id e8FGFAQ00492; Fri, 15 Sep 2000 17:15:10 +0100 (BST) (envelope-from mark) Date: Fri, 15 Sep 2000 17:15:09 +0100 From: Mark Ovens To: Ben Smithurst Cc: chat@FreeBSD.org Subject: Re: perl(1) variable declarations Message-ID: <20000915171509.A258@parish> References: <20000915130220.C257@parish> <20000915163441.A56185@strontium.scientia.demon.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <20000915163441.A56185@strontium.scientia.demon.co.uk>; from ben@FreeBSD.org on Fri, Sep 15, 2000 at 04:34:41PM +0100 Organization: Total lack of Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Fri, Sep 15, 2000 at 04:34:41PM +0100, Ben Smithurst wrote: > 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. I should have added, "in a single file program". I did wonder if multiple files might be different, but it wasn't stated anywhere that I could find. Both ways appear to work identically in a single file. I think your answer makes sense. > > ==== 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 -- 4.4 - The number of the Beastie ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message