Correcting typos: lina [lina.lastn...@gmail.com] wrote: >On Sun, Mar 11, 2012 at 10:45 PM, lina <lina.lastn...@gmail.com> wrote: >> A >> 7.803481E-01 8.228973E-01 7.515242E-01 2 1833 >> -5.5000000000 308.3889771284 5 0 7 1.7084151661 >> 1.6790503987 2.75458 >> 53558 >> 7.866901E-01 8.410519E-01 9.981456E-01 2 14485 >> -5.5000000000 269.6201271260 39 4 7 -2.5561279716 >> -3.5975355928 1.5117 >> 155069 >> C >> 7.735338E-01 9.981671E-01 7.735798E-01 2 11514 >> -5.5000000000 289.1918534266 31 1 7 -5.6311359613 >> -0.0502358314 0.0768 >> 146957 >> 5.907322E-02 6.045568E-02 3.388628E-02 1 28 >> -6.5000000000 336.0228260493 1 2 7 0.8177802191 >> 3.9634621584 -3.0314 >> 370501 >> A >> 2.764127E-02 3.230161E-02 1.633790E-02 1 51 >> -6.5000000000 319.7604886848 1 3 7 0.7583797888 >> 3.5176580829 -1.87872 >> 93439 >> 5.960780E-02 2.111333E-02 1.066835E-01 1 62 >> -6.5000000000 297.7363059936 1 1 7 2.2257828331 >> 3.7887567121 -3.4478 >> 600377 >> >> >> I am so troubled with extract the lines after A but not the lines >> under C out, so the final result is >> >> 7.803481E-01 8.228973E-01 7.515242E-01 2 1833 >> -5.5000000000 308.3889771284 5 0 7 1.7084151661 >> 1.6790503987 2.75458 >> 53558 >> 7.866901E-01 8.410519E-01 9.981456E-01 2 14485 >> -5.5000000000 269.6201271260 39 4 7 -2.5561279716 >> -3.5975355928 1.5117 >> 1550692.764127E-02 3.230161E-02 1.633790E-02 1 51 >> -6.5000000000 319.7604886848 1 3 7 0.7583797888 >> 3.5176580829 -1.87872 >> 93439 >> 5.960780E-02 2.111333E-02 1.066835E-01 1 62 >> -6.5000000000 297.7363059936 1 1 7 2.2257828331 >> 3.7887567121 -3.4478 >> 600377 >> >> >> Thanks for you suggestions, > >What I have come up so far : > >#!/usr/bin/env perl > >use strict; >use warnings; > >my $filename = "try.txt"; > >open my $fh, '<', $filename or die "Couldn't read $filename"; > > > >while (my $line = <$fh>){ > if ($line =~ /^A$/){ > ## Here I don't know how to proceed further
>From the above final result, this code worked fine, showing all the numbers >after the first A 'section', followed by all the numbers in the 2nd 'A; >section. There's no break between the 2 A sections, so the last number in the first A section: 155069 is next to the first number in the second A section: 2.764127E-02 giving you this line: 1550692.764127E-02 3.230161E-02 1.633790E-02 1 51 So depending on your version of Perl, you can replace: > print $line; with: say $line; or: print "$line/n" ; > } >} > >Thanks > >-- HTH, David Kronheim This communication is confidential. Frontier only sends and receives email on the basis of the terms set out at http://www.frontier.com/email_disclaimer. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/