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

Re: [PBML] Help a newbie - substr question.

Expand Messages
  • A. Rivera
    You could break up the line by letters I suppose.. while( ) { @letters=split(//, $_); if ($letters[60]==0 && $letters[61]==0 && $letters[62]==1 ..so on
    Message 1 of 2 , Nov 1, 2001
    • 0 Attachment
      You could break up the line by letters I suppose..
       
      while(<INPUT>)
      {
          @letters=split(//, $_);
          if ($letters[60]==0 && $letters[61]==0 && $letters[62]==1 ..so on and so on..)
          {
              $letters[69]="3";
          }
      }
       
      Agustin
       
      ----- Original Message -----
      Sent: Thursday, November 01, 2001 2:10 PM
      Subject: [PBML] Help a newbie - substr question.

      Greetings friends!

      I hope someone can tell me what I'm doing wrong - what I WANT to do is if
      I find "00150" in a certain position of a file, I want to replace one
      character in another place in the file. It should be simple but I'm
      dissappointed in myself because I can't get it right.

      Here's what I have with my notes on what I MEAN to do:

      while(<INPUT>){
      $result = $_;
      $type=substr($_,60,5);
      if ($type = 00150) {
        $new=3;
        $class=substr($result,69,1);
        $result =~ s/$class/$new/g;
      print MYOUTFILE $result,"\n";
            }
      }

         See what I WANT to do, is if I find "00150" in position 60, I want to
      CHANGE position 69 to "3".

        But what is happening is that my script is saying "Okay, position 69 for
      1 length is "4" so I'll change ALL the fours in his input file to "3" -
      just like he says!"  - so in this line:

        So my problem must be in the way I am telling perl to act - what I WANT
      to say is - "if you find 150 here, change ONLY what is in position 69
      to "3" on each line".

        What am I doing wrong??

        Thanks in advance..

        Frustrated in Texas,

        Eric







      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
    • ericvia@airmail.net
      Augustin I am going to try this ASAP! THANK YOU VERY MUCH! It seems nice! Eric
      Message 2 of 2 , Nov 1, 2001
      • 0 Attachment
        Augustin I am going to try this ASAP! THANK YOU VERY MUCH! It seems
        nice!

        Eric


        > You could break up the line by letters I suppose..
        >
        > while(<INPUT>)
        > {
        > @letters=split(//, $_);
        > if ($letters[60]==0 && $letters[61]==0 && $letters[62]==1 ..so on
        > and so on..) {
        > $letters[69]="3";
        > }
        > }
      Your message has been successfully submitted and would be delivered to recipients shortly.