There are many parties involved in making your Perl Program work and any one of them could be the culprit. Consider the following:
- There is the Perl interpreter. It has "autovivification" which would allow it to create structures as needed (so as to avoid ending up in areas that do not exist). I would not make it the first suspect though. It has been around longer than any program I have written. And people out there aren't having regular seg fault problems.
- You might be using "exec" to run another program and that program might have the segmentation fault. But if it is a simple script, then that might not be applicable.
- You are probably using a module that has pieces coded in other languages. This is the case for example if you are using a Perl module that is a wrapper around a C library. This leaves your Perl program open to seg faults in the C library. You might be sending parameters to your module that don't work for the C module and something bad ends up happening in that part of the code.
- When Perl was compiled on your system, or when the modules used were compiled and installed, there were problems that were not detected or ignored and therefore in certain circumstances, the program dies.
So as we see, we have a bit of a way to go before we blame the Perl interpreter for this one. As far as "Garbage collection", you have to keep your expectations realistic. You cannot write a Perl script to keep allocating memory and things to work hunky dory because, well you don't have a machine with infinite memory (unless I am really out of touch with chip tech).