Firstly, here is the problem with your code:
$teststring =~ "/(d\{4\})(d\{3\})(d\{3\})(d\{3\})(d\{3\})(d\{3\})/$result";
You want to use =~with a lookup operator s///. That is, the right side should not be a simple string, but s/pattern/replacement/.
\d . , \d , , [0-9], , . [0-9]{4} 0 9 . , { }.
( ) . , , , .
, , , , ( ).
/x s///, pattern .
use strict; use warnings;
while ( <DATA> ) {
s{
^
([0-9]{4})-
([0-9]{2})-
([0-9]{2})[ ]
([0-9]{2}):
([0-9]{2}):
([0-9]{2})
}{$1$2$3$4$5$6}x;
print;
}
__DATA__
Code:
2010-12-21 20:00:00
, , 5.10, :
#!/usr/bin/perl
use 5.010;
while ( <DATA> ) {
s{
^
( ?<year> [0-9]{4} ) -
( ?<month> [0-9]{2} ) -
( ?<day> [0-9]{2} ) [ ]
( ?<hour> [0-9]{2} ) :
( ?<min> [0-9]{2} ) :
( ?<sec> [0-9]{2} )
}
{
local $";
"@+{qw(year month day hour min sec)}"
}ex;
print;
}
__DATA__
Code:
2010-12-21 20:00:00