From owner-freebsd-questions Fri Aug 23 0: 4:47 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 914B937B400 for ; Fri, 23 Aug 2002 00:04:44 -0700 (PDT) Received: from topaz.mdcc.cx (topaz.mdcc.cx [212.204.230.141]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1168243E70 for ; Fri, 23 Aug 2002 00:04:44 -0700 (PDT) (envelope-from edwin@mavetju.org) Received: from k7.mavetju (topaz.mdcc.cx [212.204.230.141]) by topaz.mdcc.cx (Postfix) with ESMTP id BE8FC2B916; Fri, 23 Aug 2002 09:04:25 +0200 (CEST) Received: by k7.mavetju (Postfix, from userid 1001) id 197C26A7124; Fri, 23 Aug 2002 17:03:59 +1000 (EST) Date: Fri, 23 Aug 2002 17:03:58 +1000 From: Edwin Groothuis To: "Christopher J. Umina" Cc: freebsd-questions@freebsd.org Subject: Re: expr replacement Message-ID: <20020823070358.GM785@k7.mavetju> Mail-Followup-To: Edwin Groothuis , "Christopher J. Umina" , freebsd-questions@freebsd.org References: <20020823063308.GL785@k7.mavetju> <20020823025441.O44828-100000@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020823025441.O44828-100000@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com> User-Agent: Mutt/1.4i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 23, 2002 at 02:55:57AM -0400, Christopher J. Umina wrote: > When I do that it doesn't get the values for some reason and it gives me a > divide by zero error... I think it's because Perl's looking for it's own > variables, not the ones set in the shell script. But I can't think of a > way to put them in there. The problem with expr is that I can't get to 2 > decimal places. I really need that. You're doing something wrong [~] edwin@k7>totalsongs=1000 [~] edwin@k7>dirttl=123 [~] edwin@k7>percentage=`perl -e "print $dirttl / $totalsongs"` [~] edwin@k7>echo $percentage 0.123 [~] edwin@k7>percentage=`perl -e "printf \"%0.2f\",$dirttl / $totalsongs"` [~] edwin@k7>echo $percentage 0.12 Now what were you doing? (let me guess, single quotes) Edwin -- Edwin Groothuis | Personal website: http://www.MavEtJu.org edwin@mavetju.org | Weblog: http://www.mavetju.org/weblog/weblog.php bash$ :(){ :|:&};: | Interested in MUDs? http://www.FatalDimensions.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message