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

Re: Re : [PBML] Problem

Expand Messages
  • Louis-Philippe
    mmm, yes... thats what I thought at first sight, but look at his code, Ramesh is doing a lots of hoops counting iterations for someone who wants to change
    Message 1 of 9 , Jul 17, 2008
    • 0 Attachment
      mmm, yes...
      thats what I thought at first sight, but look at his code, Ramesh is doing a lots of hoops counting iterations for someone who wants to change in-place... so that is why I suggested something similar to the for loop you mentionned in your previous post. Maybe my interpretation is wrong, but Ramesh never answered my question about his programs intentions...

      L-P


      ----merlyn@... wrote ----

      >>>>> "Louis-Philippe" == Louis-Philippe <l0u1sph1l1ppe@...> writes:

      Louis-Philippe> I have a text file z.txt with following lines

      Louis-Philippe> *transformation
      Louis-Philippe> X Y Z
      Louis-Philippe> 10 20 30

      Louis-Philippe> Finally i need to have a the same text file as follows,

      Louis-Philippe> *transformation
      Louis-Philippe> X Y Z
      Louis-Philippe> 50 60 80

      This looks like an in-place update to me.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URLhttp://www.stonehenge.com/merlyn/>
      Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
      See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

      [Non-text portions of this message have been removed]
    • Ramesh Govinda
      Hi Philippe, Sorry for the delayed reply. I would clear my problem, Actually i am writing a script to edit the input file from LS Dyna. The input file are
      Message 2 of 9 , Jul 17, 2008
      • 0 Attachment
        Hi Philippe,

        Sorry for the delayed reply. I would clear my problem,

        Actually i am writing a script to edit the input file from LS Dyna. The input file are always very huge.
        So my motive was to replace the coordinates in x, y , z direction which is 10, 20, 30 in my case to 50, 60 ,70.

        The input file has many lines with wording transformation. that was the reason, I search for *Transformation which occurs only once in the file and then I skip the following 2 lines and then i gotot the coordinates lines where i replace the present coordinates with new value.

        Now i have a new query, instead of directly replacing  the values, i want to replace the line mathematically

        eg: I need to write in my script as follows

         input line   10+40 20+40 30+40

        Output line   50    60       70

        I want to write in the script that I will be adding 40 to the coordinates and the new line should be displayed as 50 60 70.

        I had written one code with while loop,

        open (IN,'+<','./z.txt');
        open OUT,"+<./z.txt";
        while (<IN>){
        my $file = $_;
        if ($file =~ /\*DEFINE_TRANSFORMATION/){
        print OUT $file; #print the line
        my $dump=<IN>; # skip to next line
        print OUT $dump;
        $file=<IN>; # skip to the required line

        $file =~ s/10        20        30/50        60        70/g;
        print OUT $file; 
        }
        close IN;
        close OUT;




        I have one more query to add to the above. When i run the script, the file is opened and then edited and then saved again. Is there any option in Perl, where in I could edit the text using the script without opening the file, something like a streaming function. This could make the script run faster..

        Regards,
        Ramesh
         


        --- On Thu, 7/17/08, Louis-Philippe <l0u1sph1l1ppe@...> wrote:
        From: Louis-Philippe <l0u1sph1l1ppe@...>
        Subject: Re: Re : [PBML] Problem
        To: merlyn@...
        Cc: perl-beginner@yahoogroups.com
        Date: Thursday, July 17, 2008, 6:30 PM











        mmm, yes...

        thats what I thought at first sight, but look at his code, Ramesh is doing a lots of hoops counting iterations for someone who wants to change in-place... so that is why I suggested something similar to the for loop you mentionned in your previous post. Maybe my interpretation is wrong, but Ramesh never answered my question about his programs intentions.. .



        L-P



        ----merlyn@stonehen ge.com wrote ----



        >>>>> "Louis-Philippe" == Louis-Philippe <l0u1sph1l1ppe@ spiraliens. org> writes:



        Louis-Philippe> I have a text file z.txt with following lines



        Louis-Philippe> *transformation

        Louis-Philippe> X Y Z

        Louis-Philippe> 10 20 30



        Louis-Philippe> Finally i need to have a the same text file as follows,



        Louis-Philippe> *transformation

        Louis-Philippe> X Y Z

        Louis-Philippe> 50 60 80



        This looks like an in-place update to me.



        --

        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

        <merlyn@stonehenge. com> <URLhttp://www. stonehenge. com/merlyn/>

        Smalltalk/Perl/ Unix consulting, Technical writing, Comedy, etc. etc.

        See http://methodsandme ssages.vox. com/ for Smalltalk and Seaside discussion



        [Non-text portions of this message have been removed]





























        [Non-text portions of this message have been removed]
      • merlyn@stonehenge.com
        ... Ramesh Now i have a new query, instead of directly replacing  the values, i Ramesh want to replace the line mathematically Ramesh eg: I need to write
        Message 3 of 9 , Jul 17, 2008
        • 0 Attachment
          >>>>> "Ramesh" == Ramesh Govinda <ramesh.govinda@...> writes:

          Ramesh> Now i have a new query, instead of directly replacing  the values, i
          Ramesh> want to replace the line mathematically

          Ramesh> eg: I need to write in my script as follows

          Ramesh>  input line   10+40 20+40 30+40

          Ramesh> Output line   50    60       70

          Ramesh> I want to write in the script that I will be adding 40 to the
          Ramesh> coordinates and the new line should be displayed as 50 60 70.

          You need to learn about in-place editing. Opening the
          same name for input and output, even with +<, will break for you.

          Please read the column and/or documentation I referenced previously.

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
          See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
        • Louis-Philippe
          Hi Ramesh, as Randal says, better use the inplace editing, you ll have fun with it! to give you a starter, I would code it like this: $^I = ~ ; push @ARGV,
          Message 4 of 9 , Jul 18, 2008
          • 0 Attachment
            Hi Ramesh,

            as Randal says, better use the inplace editing, you'll have fun with it!

            to give you a starter, I would code it like this:

            $^I = '~';
            push @ARGV, 'z.txt';

            while (<>) {
            s/(\d+)/40 + $1/ge;
            print;
            }

            look at Randal's column and you'll understand the code ;)

            L-P



            ----ramesh.govinda@... wrote ----

            Hi Philippe,

            Sorry for the delayed reply. I would clear my problem,

            Actually i am writing a script to edit the input file from LS Dyna. The input file are always very huge.
            So my motive was to replace the coordinates in x, y , z direction which is 10, 20, 30 in my case to 50, 60 ,70.

            The input file has many lines with wording transformation. that was the reason, I search for *Transformation which occurs only once in the file and then I skip the following 2 lines and then i gotot the coordinates lines where i replace the present coordinates with new value.

            Now i have a new query, instead of directly replacing the values, i want to replace the line mathematically

            eg: I need to write in my script as follows

            input line 10+40 20+40 30+40

            Output line 50 60 70

            I want to write in the script that I will be adding 40 to the coordinates and the new line should be displayed as 50 60 70.

            I had written one code with while loop,

            open (IN,'+<','./z.txt');
            open OUT,"+<./z.txt";
            while (<IN>){
            my $file = $_;
            if ($file =~ /\*DEFINE_TRANSFORMATION/){
            print OUT $file; #print the line
            my $dump=<IN>; # skip to next line
            print OUT $dump;
            $file=<IN>; # skip to the required line
            }
            $file =~ s/10 20 30/50 60 70/g;
            print OUT $file;
            }
            close IN;
            close OUT;

            I have one more query to add to the above. When i run the script, the file is opened and then edited and then saved again. Is there any option in Perl, where in I could edit the text using the script without opening the file, something like a streaming function. This could make the script run faster..

            Regards,
            Ramesh


            --- On Thu, 7/17/08, Louis-Philippe <l0u1sph1l1ppe@...> wrote:
            From: Louis-Philippe <l0u1sph1l1ppe@...>
            Subject: Re: Re : [PBML] Problem
            To: merlyn@...
            Cc: perl-beginner@yahoogroups.com
            Date: Thursday, July 17, 2008, 6:30 PM

            mmm, yes...

            thats what I thought at first sight, but look at his code, Ramesh is doing a lots of hoops counting iterations for someone who wants to change in-place... so that is why I suggested something similar to the for loop you mentionned in your previous post. Maybe my interpretation is wrong, but Ramesh never answered my question about his programs intentions.. .

            L-P

            ----merlyn@stonehen ge.com wrote ----

            >>>>> "Louis-Philippe" == Louis-Philippe <l0u1sph1l1ppe@ spiraliens. org> writes:

            Louis-Philippe> I have a text file z.txt with following lines

            Louis-Philippe> *transformation

            Louis-Philippe> X Y Z

            Louis-Philippe> 10 20 30

            Louis-Philippe> Finally i need to have a the same text file as follows,

            Louis-Philippe> *transformation

            Louis-Philippe> X Y Z

            Louis-Philippe> 50 60 80

            This looks like an in-place update to me.

            --

            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

            <merlyn@stonehenge. com> <URLhttp://www. stonehenge. com/merlyn/>

            Smalltalk/Perl/ Unix consulting, Technical writing, Comedy, etc. etc.

            See http://methodsandme ssages.vox. com/ for Smalltalk and Seaside discussion

            [Non-text portions of this message have been removed]











            [Non-text portions of this message have been removed]




            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.