Loading ...
Sorry, an error occurred while loading the content.

Foreach.. cicle

Expand Messages
  • nunleva
    Hello everyone again!! First of all, i would like to thanks for your help!!! I have a problem with this code: @comentarios= ( // , # , /* , */ , * ); $nome_arq
    Message 1 of 1 , Jun 3, 2003
    • 0 Attachment
      Hello everyone again!!

      First of all, i would like to thanks for your help!!!

      I have a problem with this code:

      @comentarios= ("//","#","/*","*/","*");


      $nome_arq = 'ex1.pl';
      open(ARQ, $nome_arq);
      open(OUTPUT, ">com.txt");
      @linhas_arq = <ARQ>;
      close(ARQ);
      $i=0;
      $j=0;


      foreach $com (@comentarios) {
      foreach $linha (@linhas_arq) {
      $j++;
      #if($linha=~/#/){
      #if($linha=~/\/\*/){
      #if($linha=~/\*/){
      if($linha=~/$com/){
      print OUTPUT "Linha $j: $linha";
      print "Linha $j: $linha";
      $i++;
      }
      else {
      print "Else $k!\n";
      $k++;
      last;
      }
      }
      }

      The purpose of this code is to get the values of @comentarios and
      search throughout the @linhas_arq if there is a match!!! If it does
      then he saves the content of @linhas_arq in a file!! But something is
      wrong!! I hope you can help me!!

      Another thing is, how can i search the "*"?? Because using regulars
      expressions it gives me errors, because the symbol * is reserved.

      Thank you all..

      Nuno
    Your message has been successfully submitted and would be delivered to recipients shortly.