Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm dusting off my (very basic to begin with) perl skills for a little project; however, I'm having a bit of difficulty - it seems a while loop isn't exiting after reading a text file and inserting it into a multidimensional array - no errors at all, the process takes up 99% of CPU usage and just sits there.

From the "print" statements I inserted for troubleshooting purposes, it appears that the loop itself is in fact processing all the lines in the text file itself (which doesn't end on any special characters or anything, just a newline), and then goes mumble.

I'm not sure what's going on here, as for the most part I've been following various tutorials and the Camel Book when necessary.

I'm using ActiveState's build of v5.8.6 on Windows 2000 Pro, SP4.

Code is below; thanks for all suggestions - hopefully it's just something small I've overlooked.

open( BEST, "< $best_file") || die "Sorry, can't open $best_file: $!"; @best_array = (); @NewRow = (); while( <BEST> ) { print STDOUT "\t Reading next line...\n"; $Record = $_; chomp($Record); $Record =~ s/^\s+//; @NewRow = split(/\s+/, $Record); print STDOUT @NewRow[0], " ", @NewRow[1], "\n"; push( @best_array, [@NewRow] ); print STDOUT "\t Proceeding to next line...\n"; } print STDOUT "Processing BEST for duplicates"; ...

In reply to while loop not exiting? by mabman2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-19 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found