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

Muscular Monks,

Staring at code too long, can't see why, when I run my script with the last line commented out, it runs fine and correctly prints the three expected time elements ($composite_time is dd_hh:mm:ss), but when I run it with the third line commented in, it hangs and eventually returns a server error.

@time = split(/:/, $composite_time); print "<br>@time<br>\n"; ($p3_day_hr, $p3_min, $p3_sec) = split(/:/, $composite_time);
What doth mine eyes not see?

Forget that fear of gravity,
Get a little savagery in your life.

Replies are listed 'Best First'.
Re: Split into @array works, into ($val1, $val2, ...) doesn't.
by chester (Hermit) on Sep 19, 2005 at 23:37 UTC
    Works fine when I run it. Is there other code that may be giving you a problem? Also are you using strict and warnings?

    use strict; use warnings; my $composite_time = 'dd_hh:mm:ss'; my @time = split(/:/, $composite_time); print "<br>@time<br>\n"; my ($p3_day_hr, $p3_min, $p3_sec) = split(/:/, $composite_time); print "<br>$p3_day_hr $p3_min $p3_sec<br>\n";
Re: Split into @array works, into ($val1, $val2, ...) doesn't.
by samtregar (Abbot) on Sep 20, 2005 at 00:12 UTC
    What doth mine eyes not see?

    Possibly the error log? Look there and tell us what the error is when you put in the bad line. We can help you interpret it if it's not obvious.

    -sam

      I agree about the logs and sample data would be useful as well... I have a hunch that your script has use strict; and the variables that you're assigning to the split results aren't defined before that line, but there is no way to tell without further information.

Re: Split into @array works, into ($val1, $val2, ...) doesn't.
by punch_card_don (Curate) on Sep 20, 2005 at 00:49 UTC
    OK, thanks so far. These replies already give me a partial answer - no, it's not just some syntax stupidly mis-typed in these lines, which I thought it was. (You, know, hour 12 of the day and this is the n-th time in the last two hours you've gone looking for the forgotten semi-colon).

    Thanks - will go looking deeper.

    Forget that fear of gravity,
    Get a little savagery in your life.

Re: Split into @array works, into ($val1, $val2, ...) doesn't.
by polypompholyx (Chaplain) on Sep 20, 2005 at 10:00 UTC
    My eyes do not see lexical variables. Are the (presumably global) p3_ variables being re-used somewhere else later in the script, where their values cause the script to barf? Try putting use CGI::Carp 'fatalsToBrowser';, at the top of your CGI script and you may get something more helpful than a bald 500 server error.
      Great minds think alike - already have use CGI::Carp 'fatalsToBrowser'; in there. That's the maddening thing - it produces nothing.

      Forget that fear of gravity,
      Get a little savagery in your life.