Hi !

This sctipt work with \insert{aaa.tex} but dont work with \insert aaa.tex


What I must do ?!

while(/^\\insert\{(.*?)(\.tex)?\}/){
      $pries=$`."\n";
      $nekeisk=$&;
      $vardas=$1;
      $po=$';
      $failiukas=$1.".tex";
         
      if(-e "$dir/$failiukas"){
                               open (IN2,"<$failiukas") || die "negaliu atidaryti $failiukas failo.\n";
                               $vidus=<IN2>;
                               close IN2;
     
                               $visas=$visas.$pries.$vidus."\n";
                               $_=$po;
                               print "Idetas failas $failiukas\n";
                              }
     else{
           $visas=$visas.$pries.$failiukas."\n";
           $_=$po;
           print "$failiukas failas nerastas!!!!!!\n";
         }
                               }
$visas=$visas.$_;
$_=$visas;
$visas = "";

try:

while(/^\\insert{?(.*?)(\.tex)?}?/){

you don't need to escpae the {} brackets with \