in reply to Re: Script halting without error?
in thread Script halting without error?

It actually exits. I'll see what I can do to post a reproduction.

Edit: Okay, this code does the same thing. (It stops and the print never shows up.)

use strict; use warnings; my %hash = (); foreach my $a (1..500) { foreach my $b (1..4000) { foreach my $c (1..10) { foreach my $d (1..7) { $hash{$a}{$b}{$c}{$d} = $d; } } } } print "here\n";

I assume it's just running out of memory somehow, but I don't know why there's no error message or what I should do about it.

Replies are listed 'Best First'.
Re^3: Script halting without error?
by zentara (Cardinal) on Dec 13, 2005 at 13:55 UTC
    You didn't say what version of windows you are testing this on. I usually avoid windows, but I ran into a similar problem awhile back, when I was trying to see if a threaded program(which ran fine on linux) would work on windows.

    The program created a big hash of shared variables for the threads. On WindowsME, it just crashed after a bit. On WindowsXP it ran fine. So I know there is some big differences in the way Windows handles memory, between versions. The code was something like this:

    #############shared hashes for xml processor################# my @chs = (1..99); # setting this to 2 works on windowsME # but will bog down over 3, and crash # at values like 60 #WindowsXP ran it fine my $max_prog_chan = 60; #XP ok my %days; foreach my $channel(@chs){ foreach my $count(0..$max_prog_chan){ #print "$channel $count\n"; share $days{$channel}{$count}{'channel'}; share $days{$channel}{$count}{'channel_info'}; share $days{$channel}{$count}{'episode_num'}; share $days{$channel}{$count}{'start'}; share $days{$channel}{$count}{'stop'}; share $days{$channel}{$count}{'makedate'}; share $days{$channel}{$count}{'description'}; share $days{$channel}{$count}{'title'}; share $days{$channel}{$count}{'writer'}; share $days{$channel}{$count}{'director'}; share $days{$channel}{$count}{'actors'}; share $days{$channel}{$count}{'rating'}; share $days{$channel}{$count}{'length'}; share $days{$channel}{$count}{'category'}; share $days{$channel}{$count}{'star_rating'}; } }

    I'm not really a human, but I play one on earth. flash japh
Re^3: Script halting without error?
by spiritway (Vicar) on Dec 14, 2005 at 05:23 UTC

    Well, you have 140 million iterations of an operation, or a set of operations. My question is, how do you know whether it's still grinding along, and hasn't finished, versus it chokes and dies. You say it stops and the print never shows up. Well, does the program end, and you get your cursor back? My guess is that your program doesn't stop, it just keeps struggling to finish the loops, and you have nothing to tell you it's still working.

    You might want to try adding a line in one of the earlier loops that prints something (even a period).

    use strict; use warnings; my %hash = (); foreach my $a (1..500) { print "."; # <- Show we're alive by printing a dot... foreach my $b (1..4000) { foreach my $c (1..10) { foreach my $d (1..7) { $hash{$a}{$b}{$c}{$d} = $d; } } } } print "here\n";

    Anyway, that's just my thoughts on it - YMMV.