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

Hi, maybe you can find the error in my code.
.... my $datum0 = date_extra($file); textsformat("$entry/$file", $entry , $datum0); system "cat /home/dub/S/programming/perl/dp/textsformat.out +put >> $entry.tab"; }; }; closedir(DIR); }; }; sub date_extra { my $file0 = shift; my $date = substr($file0, 9,6); $date =~ s/(\d{2})(\d{2})(\{2})/$3\.$2\.20$1/; # why this command do +es not work return $date; }; ... ...
file looks like "text....030525_00_07-2" (.:other characters) result: date:030525 instead of 25.05.2003 Where is the error ???? Thank you for your help. star 7

edited: Mon Jun 2 13:48:38 2003 by jeffa - title change (was: HELP - I can`t find error ...)

Replies are listed 'Best First'.
Re: Need help with date regex
by Aristotle (Chancellor) on Jun 01, 2003 at 12:20 UTC
    s/(\d{2})(\d{2})(\{2})/$3\.$2\.20$1/;
    Are you sure you meant it that way? Also, you should get in the habit of treating years as numbers, not strings, although that's not likely to be a problem in this specific case.
    s/(\d{2})(\d{2})(\d{2})/"$3.$2." . (2000 + $1)/e;

    Makeshifts last the longest.

      @juerd,Aristotle
      Thank you for your help. It works. What a stupid error.
      star7
Re: Need help with date regex
by Juerd (Abbot) on Jun 01, 2003 at 12:19 UTC