Hi,

I have written something as following,


my $template_file="template";
my $h_data_file="h_data";

open my $fh1, '<', $template_file;
open my $fh2, '<', $h_data_file;


while(<$fh2>){
        my ($h11,$h21,$h22,$h33)=split ' ', $_;
        &substitute($h11,$h21,$h22,$h33);
        say $h11,$h21,$h22,$h33;
}

sub substitute{
        my($h11,$h21,$h22,$h33)=@_;
        while(<$fh1>){
                s/\$h11/$h11/g; 
                s/\$h21/$h21/g; 
                s/\$h22/$h22/g;
                s/\$h33/$h33/g;
                print $_;
        };
}


Strangely, it only substituted once, but not for the later once.

Thanks ahead for your suggestions, I don't know why,

Best regards,



$ ./process.pl
Cu
 1.00000000000000000
     3.391687673      0.0000    .0000000000000000
     -1.69584      2.93729    .0000000000000000
      .000000000000000     .00000000000000    56.9483
  24
Selective dynamics
Direct
   .3333333333333286   .6666666666666643   .1185284822865782   F   F   F
   .6666666666666643   .3333333333333357   .1516999186094878   F   F   F
   .0000000000000000   .0000000000000000   .1848589208454497   T   T   T
   .3333333333333286   .6666666666666643   .2180206715133299   T   T   T
   .6666666666666643   .3333333333333357   .2512257534097896   T   T   T
   .0000000000000000   .0000000000000000   .2843786564112883   T   T   T
   .3333333333333286   .6666666666666643   .3175644456970751   T   T   T
   .6666666666666643   .3333333333333286   .3507257887572191   T   T   T
   .0000000000000000   .0000000000000000   .3838973926822139   T   T   T
   .3333333333333286   .6666666666666643   .4170756687740492   T   T   T
   .6666666666666643   .3333333333333357   .4502328669501330   T   T   T
   .0000000000000000   .0000000000000000   .4834245346861108   T   T   T
   .3333333333333286   .6666666666666643   .5165754653138892   T   T   T
   .6666666666666643   .3333333333333357   .5497671330498669   T   T   T
   .0000000000000000   .0000000000000000   .5829243312259508   T   T   T
   .3333333333333286   .6666666666666643   .6161026073177861   T   T   T
   .6666666666666643   .3333333333333357   .6492742112427810   T   T   T
   .0000000000000000   .0000000000000000   .6824355543029248   T   T   T
   .3333333333333286   .6666666666666643   .7156213435887117   T   T   T
   .6666666666666643   .3333333333333357   .7487742465902104   T   T   T
   .0000000000000000   .0000000000000000   .7819793284866701   T   T   T
   .3333333333333286   .6666666666666643   .8151410791545503   T   T   T
   .6666666666666643   .3333333333333357   .8483000813905122   F   F   F
   .0000000000000000   .0000000000000000   .8814715177134218   F   F   F
3.391687673-1.695842.9372956.9483
3.276920216-1.638462.837957.5811
3.169512596-1.584762.7448858.2139
3.067525189-1.533762.6565558.8466
2.972759622-1.486382.5744959.4794
2.881367314-1.440682.4953460.1121
2.799696123-1.399852.4246160.7449
2.735964536-1.367982.3694161.3777
2.677185505-1.338592.3185162.0104
2.6608252-1.330412.3043462.3268
2.61797715-1.308992.2672362.6432
2.59226372-1.296132.2449762.9596
2.570682531-1.285342.2262863.2759
2.548365359-1.274182.2069563.5923
2.522084608-1.261042.1841963.9087
2.500649083-1.250322.1656364.2251
2.478423909-1.239212.1463864.5414
2.445365974-1.222682.1177565.1742
2.399198331-1.19962.0777765.807
2.35965454-1.179832.0435266.4397
2.328643561-1.164322.0166667.0725
2.295662291-1.147831.988167.7052
2.260580402-1.130291.9577268.338
2.234337983-1.117171.9349968.9708
2.204392647-1.10221.9090669.6035

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to