Text Parsing

Discussion in 'Perl Misc' started by Shalini Joshi, Jun 18, 2004.

  1. Hi!

    Thanks Jeff!!

    I cant seem to figure out why your code (as is) goes into an infinite
    loop when I try and run it??

    My initial approach was something like this:
    $/='FPR';
    <>; #empty record
    while(<>){
    chomp;
    print $_ ;


    (Obviously it doesnt do what i want it to do..was just trying it out
    to see how it works)

    THanks..

    Shalini
    Shalini Joshi, Jun 18, 2004
    #1
    1. Advertising

  2. Shalini Joshi

    Bob Walton Guest

    Shalini Joshi wrote:

    ....
    > I cant seem to figure out why your code (as is) goes into an infinite
    > loop when I try and run it??
    >
    > My initial approach was something like this:
    > $/='FPR';
    > <>; #empty record
    > while(<>){
    > chomp;
    > print $_ ;
    >
    >
    > (Obviously it doesnt do what i want it to do..was just trying it out
    > to see how it works)



    Well, that code doesn't go into an infinite loop for me. It generates a
    compile error. Fixing that by adding the missing }, it works fine,
    assuming that what you want to do is take the lines of a text file with
    records separated by FPR and put them all on one line with no whitespace
    in between. Are you sure the program isn't just waiting for you to
    enter records separated by FPR on standard input (which is where it will
    look for input unless you give it some filenames as arguments)? It will
    continue to do that until you give it an end-of-file. And note that
    your "empty record" must be separated from the next record by the
    character sequence FPR , not a newline. And depending upon your OS and
    whether you have STDIN coming from a console, a file or something else,
    you might not get anything until the OS thinks you sent a line, using
    the OS's definition of a line (terminated by the OS's newline sequence),
    not Perl's FPR idea of a newline which you gave Perl.


    ....


    > Shalini



    --
    Bob Walton
    Email: http://bwalton.com/cgi-bin/emailbob.pl
    Bob Walton, Jun 19, 2004
    #2
    1. Advertising

  3. Bob Walton <> wrote in message news:<>...

    > Well, that code doesn't go into an infinite loop for me. It generates a
    > compile error.


    No, no...am sorry for the confusion, I meant the code that Jeff
    posted(the one with the redo etc..that one was going into an infinite
    loop)...This code(which you tried) is hte one i had started out with
    initially before consulting the Group..:)...

    THanks for the feedback though.

    Sorry about the confusion!

    Regards,

    Shalini
    Fixing that by adding the missing }, it works fine,
    > assuming that what you want to do is take the lines of a text file with
    > records separated by FPR and put them all on one line with no whitespace
    > in between. Are you sure the program isn't just waiting for you to
    > enter records separated by FPR on standard input (which is where it will
    > look for input unless you give it some filenames as arguments)? It will
    > continue to do that until you give it an end-of-file. And note that
    > your "empty record" must be separated from the next record by the
    > character sequence FPR , not a newline. And depending upon your OS and
    > whether you have STDIN coming from a console, a file or something else,
    > you might not get anything until the OS thinks you sent a line, using
    > the OS's definition of a line (terminated by the OS's newline sequence),
    > not Perl's FPR idea of a newline which you gave Perl.
    >
    >
    > ...
    >
    >
    > > Shalini
    Shalini Joshi, Jun 20, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GIMME
    Replies:
    2
    Views:
    869
    GIMME
    Feb 11, 2004
  2. Naren
    Replies:
    0
    Views:
    570
    Naren
    May 11, 2004
  3. Christopher Diggins
    Replies:
    0
    Views:
    599
    Christopher Diggins
    Jul 9, 2007
  4. Kai Schlamp
    Replies:
    1
    Views:
    410
    Arne Vajhøj
    Mar 27, 2008
  5. Domenico Discepola

    Assistance parsing text file using Text::CSV_XS

    Domenico Discepola, Sep 1, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    444
    Domenico Discepola
    Sep 2, 2004
Loading...

Share This Page