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

RE: [PBML] Re: see this imp problem about putting a comma if the next line is not a heading

Expand Messages
  • Eric Thibodeau
    Maybe if you should chomp your line before adding the , ie: while ( ){ #read a line from file IN into $_ chomp($_); #removes newline
    Message 1 of 2 , Mar 30, 2001
    • 0 Attachment
      Maybe if you should chomp your line before adding the ","

      ie:
      while (<IN>){ #read a line from file IN into $_

      chomp($_); #removes newline

      $newvar = "$_ ,";
      #print OUT $newvar;
      $newvar =~ s/,'/'/g;
      print OUT $newvar;
      }


      -----Original Message-----
      From: shoeb_jafri@... [mailto:shoeb_jafri@...]
      Sent: Friday, March 30, 2001 12:21 PM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] Re: see this imp problem about putting a comma if the
      next line is not a heading


      --- In perl-beginner@y..., "Greg" <webmaster@b...> wrote:
      > --- In perl-beginner@y..., shoeb_jafri@h... wrote:
      > > Input:
      > >SINCE THERE R MORE LINES, I
      > > PUT A COMMA AT THE END OF THE LINE.
      > > IF A LINE START WITH ^' THEN THE LINE ONE BEFORE, SHOULD NOT HAVE
      A
      > > COMMA AT THE END OF THE LINE...AS U SEE TO THE OUTPUT..
      > > C112.1 C111.1 DOES NOT HAVE A COMMA AT THE END OF THE LINE SINCE
      > THE
      > > NEXT LINE START WITH A ' SIGN.
      > > I HOPE U GUYS/GALS CAN HELP ON THIS ONE.
      > > THANKS
      > ==================
      > Simple. Just read the input data in one line at a time and add a
      > comma to the end of each line. Save it all in some variable.
      > Then globally replace every occurrance of /comma,end-of-line,'/
      > with /end-of-line, '/
      >
      > Greg S.
      Greg this is my input file...............
      '+1.8V' ; R158.1 C301.1 C423.1 C413.1 C412.1 CR2.A R757.2 C73.1 C69.1
      C72.1 C64.1 C66.1 IC27.N13 IC27.N4 IC27.L3 IC27.B15
      IC27.C6 IC27.D4 IC27.R15 IC27.A9 IC27.B2 IC27.D13
      IC27.F14 IC27.J15 IC27.P11 IC27.R2 IC27.R8
      L10.1 C65.1 C71.1 C67.1 C75.1 C70.1 C74.1 C68.1 IC31.N13 IC31.N4
      IC31.L3 IC31.B15 IC31.C6 IC31.D4 IC31.R15 IC31.A9
      IC31.B2 IC31.D13 IC31.F14 IC31.J15 IC31.P11
      IC31.R2 IC31.R8 C85.1 C94.1 C93.1 C90.1 C89.1 C86.1 C83.1
      L9.1 C87.1 C84.1 C88.1 C92.1 C91.1 C149.1 C145.1 C141.1 IC30.N13
      IC30.N4 IC30.L3 IC30.B15 IC30.C6 IC30.D4 IC30.R15
      IC30.A9 IC30.B2 IC30.D13 IC30.F14 IC30.J15 IC30.P11
      IC30.R2 IC30.R8 C150.1 C146.1 L8.1 C151.1 C148.1 C147.1 C144.1
      C143.1 C142.1 C140.1 C123.1 C127.1 C126.1 C121.1 IC29.N13 IC29.N4
      IC29.L3 IC29.B15 IC29.C6 IC29.D4 IC29.R15 IC29.A9
      IC29.B2 IC29.D13 IC29.F14 IC29.J15 IC29.P11
      IC29.R2 IC29.R8 C129.1 C125.1 C122.1 L7.1 C132.1 C128.1 C124.1
      C131.1 C130.1 C103.1 C107.1 C108.1 IC28.N13 IC28.N4 IC28.L3
      IC28.B15 IC28.C6 IC28.D4 IC28.R15 IC28.A9 IC28.B2
      IC28.D13 IC28.F14 IC28.J15 IC28.P11 IC28.R2
      IC28.R8 C104.1 C102.1 C106.1 L6.1 C105.1 C113.1 C110.1 C109.1
      C112.1 C111.1
      '+1.8VB' ; C26.1 C294.1 C25.1 C355.1 C24.1 C302.1 IC18.N9 IC18.N12
      IC18.P10 IC18.P15 IC18.R7 IC18.R14 IC18.AA1
      IC18.AA22 IC18.M22 IC18.B1 IC18.B22 IC18.H9
      IC18.J8 IC18.J13 IC18.K11 IC18.K14 IC18.L10
      IC18.M13 C293.1 L5.2 C419.1 IC59.3

      after running my code ..this is my output file:
      ,'+1.8V' ; R158.1 C301.1 C423.1 C413.1 C412.1 CR2.A R757.2 C73.1 C69.1
      ,C72.1 C64.1 C66.1 IC27.N13 IC27.N4 IC27.L3 IC27.B15
      ,IC27.C6 IC27.D4 IC27.R15 IC27.A9 IC27.B2 IC27.D13
      ,IC27.F14 IC27.J15 IC27.P11 IC27.R2 IC27.R8
      ,L10.1 C65.1 C71.1 C67.1 C75.1 C70.1 C74.1 C68.1 IC31.N13 IC31.N4
      ,IC31.L3 IC31.B15 IC31.C6 IC31.D4 IC31.R15 IC31.A9
      ,IC31.B2 IC31.D13 IC31.F14 IC31.J15 IC31.P11
      ,IC31.R2 IC31.R8 C85.1 C94.1 C93.1 C90.1 C89.1 C86.1 C83.1
      ,L9.1 C87.1 C84.1 C88.1 C92.1 C91.1 C149.1 C145.1 C141.1 IC30.N13
      ,IC30.N4 IC30.L3 IC30.B15 IC30.C6 IC30.D4 IC30.R15
      ,IC30.A9 IC30.B2 IC30.D13 IC30.F14 IC30.J15 IC30.P11
      ,IC30.R2 IC30.R8 C150.1 C146.1 L8.1 C151.1 C148.1 C147.1 C144.1
      ,C143.1 C142.1 C140.1 C123.1 C127.1 C126.1 C121.1 IC29.N13 IC29.N4
      ,IC29.L3 IC29.B15 IC29.C6 IC29.D4 IC29.R15 IC29.A9
      ,IC29.B2 IC29.D13 IC29.F14 IC29.J15 IC29.P11
      ,IC29.R2 IC29.R8 C129.1 C125.1 C122.1 L7.1 C132.1 C128.1 C124.1
      ,C131.1 C130.1 C103.1 C107.1 C108.1 IC28.N13 IC28.N4 IC28.L3
      ,IC28.B15 IC28.C6 IC28.D4 IC28.R15 IC28.A9 IC28.B2
      ,IC28.D13 IC28.F14 IC28.J15 IC28.P11 IC28.R2
      ,IC28.R8 C104.1 C102.1 C106.1 L6.1 C105.1 C113.1 C110.1 C109.1
      ,C112.1 C111.1
      ,'+1.8VB' ; C26.1 C294.1 C25.1 C355.1 C24.1 C302.1 IC18.N9 IC18.N12
      ,IC18.P10 IC18.P15 IC18.R7 IC18.R14 IC18.AA1
      ,IC18.AA22 IC18.M22 IC18.B1 IC18.B22 IC18.H9

      IT MEANS IT IS NOT WORKING PROPERLY..
      HERE IS MY CODE..
      while (<IN>){ #read a line from file IN into $_
      $newvar = "$_ ,";
      #print OUT $newvar;
      $newvar =~ s/,'/'/g;
      print OUT $newvar;
      }
      PLEASE LET ME KNOW WHAT IS WRONG .......






      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    Your message has been successfully submitted and would be delivered to recipients shortly.