On Feb 11, 2004, at 2:35 PM, Michael S. Robeson II wrote:

    next unless s/^\s*(\S+)//;
    my $name = $1;

Well, if we're reading name to name, the thing right a the beginning of our sequence is going to be a name, right? The above removes the name, and saves it for later use.

OK, I think this is were my problem is. That is how does it know that the characters as in "bob" or "fred" are the names and not mistaking the sequence of letters "agtcaccgatg" to be placed in memory ($name). Basically I am reading the following:


next unless s/^\s*(\S+)//;

as "Go to the next line

Not line. We're not reading lines anymore. We're reading chunks of characters ending in a >, remember?


unless you see a line with zero or more whitespace characters followed by one or more non-whitespace characters

Not quite. ^ matching at the beginning of our chunk, not the beginning of a line. It's "unless you start with zero-or more whitespace characters, following by one or more non-white-space characters..."


Those "one or more non-white-space characters" are going to be the name at the beginning. There's also going to be a \n (a whitespace character) at the end of that name, to keep it from going into the sequence.

and save the non-whitespace characters in memory."

In my English, it reads, "Unless you can rip a name off the front of this chunk, skip it." ;) So the only time it ever does any skipping, is if the whole chunk is whitespace (or nothing), which would keep it from finding a name. I imagine this only skips the very first read, which probably won't have anything interesting between the front of the file and the first > character.


If this is correct then how can perl tell the difference between the lines containing "bob" or "fred" (and put then in memory) and the "acgatctagc" (and not put these in memory) because both lines of data seem to fit the expression pattern to me. I think it has something to do with how perl is reading through the file that makes this work?

Yes, it's reading > to >. Also, ^ matches at the beginning of a string, not a line, by default.


That's why I gave you the paragraph version earlier today. I thought it was a little easier to follow. ;)

So, there is something I am "missing", not noticing or realizing here.
Maybe I've been staring at the code for far to long and should take a break! :-)

Definitely. Have a break. It clears the mind. Come back refreshed and reread this message until you break through the fog.


Or just ask more questions and I'll try again. :D

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to