[GRASS5] $LOCATION or not $LOCATION ?
Eric G. Miller
egm2 at jps.net
Thu May 16 08:22:50 EDT 2002
On Thu, May 16, 2002 at 12:17:09PM +0100, Glynn Clements wrote:
> Normally, it's preferable to use "normal" variables rather than
> environment variables, as environment space is a limited resource (and
> shared with the argument list, so consuming environment space reduces
> the maximum length of an argument list).
I don't think adding environment variables in a perl script runs into
those same limitations unless the script spawns children. 'Course, if
the script doesn't spawn any children, there's probably no reason to
use the %ENV hash to begin with (unless you're lazy and want a special
global hash).
Anyway, the point was to use "chomp" to remove newlines, not anything
about the variables. I just use %ENV as an example, as that was what
Markus' script was doing...
Maybe the script below is a better example? Only one g.gisenv call.
#! /usr/bin/perl -w
local %gisenv;
my $input = `g.gisenv`;
my @arr = split /\n/, $input;
foreach $item (@arr) {
my ($k,$v) = split /=/, $item;
$v =~ s/\'//gc;
$gisenv{$k} = $v;
print "\$gisenv{$k} = $gisenv{$k}\n";
}
--
Eric G. Miller <egm2 at jps.net>
More information about the grass-dev
mailing list