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

Re: PROBLEM......does not work

Expand Messages
  • Damien Carbery
    I think Charles gave a good example of this a few days ago. I think if you under $/; it will read the whole file in one go. Then when you do the s/// you have
    Message 1 of 5 , Mar 30, 2001
    • 0 Attachment
      I think Charles gave a good example of this a few days ago.
      I think if you
      under $/;
      it will read the whole file in one go.
      Then when you do the
      s///
      you have to have to say
      s///mg
      m = treat string as multiple lines and g = replace all occurances.

      I think the resulting code will be something line:
      undef $/;
      $newvar = <IN>;
      $newvar =~ s/,'/'/mg;
      print OUT $newvar;

      You'll probably have to play around with the substitution line.

      --- In perl-beginner@y..., shoeb_jafri@h... wrote:
      > --
      > I TRIED IT . IT DOES NOT WORK...I THINK THE PROBLEM IS READING MORE
      > THAN ONE LINE AT A TIME SINCE I HAVE
      > $newvar =~ s/,'/'/g; but between comma and ' there is a end of line
      > character like $ and if i want to replace that
      > like $newvar =~ s/,$'/'/g; it gives me some " use of uninitialized
      > value in concatenation (.)" error mesg.
      > so i think tell me how i can read multiple lines at a time or
      > something like that/////////
      > - In perl-beginner@y..., "Damien Carbery" <daymobrew@y...> wrote:
      > > Try escaping the single quotes in your substitution
      > > i.e. change:
      > > $newvar =~ s/,'/'/g;
      > > to
      > > $newvar =~ s/,\'/\'/g;
      > >
      > > I haven't tried this.
      > >
      > > --- In perl-beginner@y..., shoeb_jafri@h... wrote:
      > > > 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 . I WANT TO REPLACE ,' WITH A '
      > > ONLY.
      > > > FOR SOME REASON IT IS NOT WORKING
    Your message has been successfully submitted and would be delivered to recipients shortly.