use strict;
my $str = '1 0 0 0 0 1 0 0 0 1 0 0 0 1 3024.dat
#linetype color XROT YROY ZROT XPOS YPOS ZPOS XCAM YCAM ZCAM XSCA YSCA ZSCA FILE';
my $regex = qr/^\h*
(?<linetype>[0123456])\h+
(?<color> (?&Number) )\h+
(?<xrot> (?&Number) )\h+ (?<yrot> (?&Number) )\h+ (?<zrot> (?&Number) )\h+
(?<xpos> (?&Number) )\h+ (?<ypos> (?&Number) )\h+ (?<zpos> (?&Number) )\h+
(?<xcam> (?&Number) )\h+ (?<ycam> (?&Number) )\h+ (?<zcam> (?&Number) )\h+
(?<xsca> (?&Number) )\h+ (?<ysca> (?&Number) )\h+ (?<zsca> (?&Number) )\h+
(?<filename>\S+[.]\S+)
$
(?(DEFINE)
(?<Number> [-]? \d+ (?> [.]\d* )? (?> [Ee] [+-]? \d+ )? )
)/mxp;
my $subst = '${linetype} ${color} ($xrot,$yrot,$zrot) {$xpos,$ypos,$zpos} <$xcam,$ycam,$zcam> [$xsca,$ysca,$zsca] "$filename"';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html