Text Parsing

S

Shalini Joshi

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
 
B

Bob Walton

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.


....
 
S

Shalini Joshi

Bob Walton said:
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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top