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

I have some code that worked like a champ in version 5.6 but now that I'm using 5.8 it's not. The following is a small clip:
$date=`/bin/date`; print "date is -->$date<--"; print $new_sock "[$client_ipnum] $client_host connecte +d\n";
Now, about 1 out of 4 times $date is empty. What's going on here? How can that happen?

Replies are listed 'Best First'.
Re: Simple stuff breaks in 5.8?
by Fletch (Bishop) on Dec 16, 2002 at 20:20 UTC

    Of course one could question `/bin/date` being used when there's the perfectly good scalar localtime or use POSIX qw( strftime ).

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Simple stuff breaks in 5.8?
by neilwatson (Priest) on Dec 16, 2002 at 19:50 UTC
    Do you have:
    use strict; use warnings;

    In your code? They should provide you with some useful feedback about your code.

    Neil Watson
    watson-wilson.ca

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Simple stuff breaks in 5.8?
by CountZero (Bishop) on Dec 16, 2002 at 20:17 UTC

    What happens if you only run

    $date=`/bin/date`; print "date is -->$date<--";

    Do you see the same odd behaviour?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Donno. You think it'll miss a heartbeat like the other? Or is that maybe caused by the socket? I'll give it a try...
        With the following small program I didn't see any hickups at all:
        #! /usr/bin/perl -w use warnings; while (){ $date=`/bin/date`; print "date is -->$date<--\n"; sleep (2); }