RaynMan has asked for the wisdom of the Perl Monks concerning the following question:

Afternoon Monks! New to perl...I am having a bit of a problem when attempting to pass a large text file to powershell and from powershell a registry value is placed in a defined location hklm:\software\policies. Powershell seems to not be able to handle files in excess of 45kb. Once the registry key is created it cannot be added to or modified. Also, Unfortunatly the registry value must be much larger. So my real question is " Is there anyway to split up a .txt file in perl and then pass multiple arguments to powershell so that it reads the text file as a huge string and not individual submissions. Perhaps a buffer is needed to store such large values? Is there any alternative to powershell which can handle larger .txt files Thanks

  • Comment on Split large text file into smaller values so powershell can handle transfering the value to a registry location

Replies are listed 'Best First'.
Re: Split large text file into smaller values so powershell can handle transfering the value to a registry location
by affc (Scribe) on Jun 17, 2010 at 19:41 UTC
    Perhaps I misunderstood your problem, but couldn't you use Win32::TieRegistry, for instance, to write to the registry, bypassing Powershell?
Re: Split large text file into smaller values so powershell can handle transfering the value to a registry location
by aquarium (Curate) on Jun 18, 2010 at 03:32 UTC
    You probably need to re-evaluate some of your assumptions about this arbitrary supposed limit for powershell. it's easy to start seeing false patterns. process or file monitor utilities are helpful. Also "send the cat to the vet" as i like to call it, i.e. cat -vet thefile.txt on unix/cygwin to look for strange characters that can break reading a file. As has been mentioned you can use Tie::Registry, or even send a .reg file directly to windows registry editor etc.
    the hardest line to type correctly is: stty erase ^H
Re: Split large text file into smaller values so powershell can handle transfering the value to a registry location
by zek152 (Pilgrim) on Jun 17, 2010 at 19:42 UTC

    I could not find any reference to a 45kb size limit on files. Could you show where you found that limit (or is it solely from personal experience)? 45kb seems like a pretty small size for a modern scripting language that is less than 4 years old. It might be possible that you are not inputing the file correctly (ie storing the whole file at once which could be seen as a memory leak instead of line by line).