You may have to tweak $max to get it to fail depending on how many ENV variables are predefined on your system. It fails like this:use warnings; use strict; my $max = 69; #-- tweak this to get it to fail foreach my $i ( 1 .. $max ) { my $t = "ENV$i"; my $m = max( $i, 20); $ENV{$t} = "big string" x $m; } my @env = keys %ENV; print "# of ENV: ", scalar keys %ENV, "\n"; #-- calculate the lenght of the env list my $env_str = ''; foreach my $key ( keys %ENV ) { $env_str .= "$key=" . $ENV{$key} . " "; #-- space represents \0 inter +nal in pointer } print "Length ENV str: ", (length( $env_str) + 1), "\n"; print `set`; print "RC: ", $?, "\n"; #------------------------------------------------------------------ sub max { my ( $i, $j ) = @_; if ( $i > $j ) { return $i; } return $j; }
.. but I think it's the length of the string, not the number of ENV variables, that affects whether it fails. E.g, change the max on the "big string" to 40 from 20, and it fails at 118 env variables and a length of 30785. I looked in the source code and it indicates that the cmd process is created with CreateProcess that passes in (LPVOID)env, /* inherit environment */. I cannot find any limit on the env string on the Microsoft site. Is there a magic number limit internal to perl? Thanks in advance. - j# of ENV: 127 Length ENV str: 30798 RC: -1
In reply to Win32 backticks fail when too many ENV vars by jimbojones
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |