in reply to Re: Convert date
in thread Convert date

Why does the line print Use of uninitialized value in substitution (s///) How to avoid it

Replies are listed 'Best First'.
Re^3: Convert date
by Corion (Patriarch) on Jul 15, 2009 at 09:39 UTC

    The following code does not print any warning for me:

    >perl -wle "my $date='20080501'; $date =~ s/^(\d{4})(\d{2})(\d{2})$/$1 +-$2-$3/;print $date" 2008-05-01

    So the problem must be with your other code and/or how you're using it. My guess is that $date in your case is not defined. Print out $date before trying a substitution on it:

    print "I think \$date is [$date]\n";