I am using a perl script to replace some lines in a data file. The perl script is called from the matlab program, which is written to the data file before the perl script is executed and after it is executed.
Then my Matlab program will be written to the data file, but for some reason this is not the case.
Here is a minimal example: Matlab code:
f = fopen('output.txt','a'); fprintf(f,'This is written\n'); perl('replace.perl','output.txt'); fprintf(f,'This is not\n'); [fname perm] = fopen(f) type('output.txt'); fclose(f);
perl script:
#!/usr/bin/perl -i while(<>){ s/This/This here/; print; } close;
The variables fname and perm are correctly assigned. The conclusion of type is only "It is written here."
I am new to perl and so I probably made a rookie error in a script that I cannot find. Thanks for the help.
source share