Danny has asked for the wisdom of the Perl Monks concerning the following question:
perl -we 'my $x = `cat file1`' # seg faults
perl -we 'my @x = `cat file1`' # works fine
perl -we 'my $x = `cat file2`' # works fine
So it seems that in scalar context if the output of the command in backticks is greater than 2**31-1 then it segfaults. It seems the backticks use some buffer that has a size limit. The results were the same on 64 bit linux and cygwin.perl -we 'my $x = `cat file2`; $x .= `cat file2`' # works fine
Update: Curiously if I do:
I get aperl -we 'my $x = `cat file2 file2`'
orOut of memory in perl:util:safesysmalloc (cygwin perl 5.40)
instead of aOut of memory! (linux perl 5.38)
Segmentation fault
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $x = `cat big_file` seg faults
by tonyc (Hermit) on Sep 13, 2024 at 02:28 UTC | |
|
Re: $x = `cat big_file` seg faults
by LanX (Saint) on Sep 09, 2024 at 22:54 UTC | |
|
Re: $x = `cat big_file` seg faults
by choroba (Cardinal) on Sep 10, 2024 at 10:01 UTC | |
by cavac (Prior) on Sep 10, 2024 at 10:16 UTC | |
by choroba (Cardinal) on Sep 10, 2024 at 11:41 UTC |