----- Original Message ----- From: "Michael Fowler" <[EMAIL PROTECTED]> To: "Egor Brandt" <[EMAIL PROTECTED]> > On Wed, Dec 19, 2001 at 10:14:00PM +0100, Egor Brandt wrote: > > #!/usr/bin/perl -w > > while ( < i am fred flintstone >) { > > The text between the angle brackets is not what you're matching against; > it's either a filehandle that you're reading from, or a globbing pattern to > match files against in the current directory. Not having Learning Perl on > hand I couldn't tell you which, but I'm guessing it's a filehandle to read > from. > > If the text doesn't explain what that construct means then it should have > already been established. Flip back through the book and read about > filehandles.
Since I have the book, I would like to help a little. In page 103 of "Learning Perl" 3rd edition, it is not refering to read a filehandle. It is very clear that the Author is trying to explain certain things and that the code is not intended to be used as an end product. I am very impressed with the Author's quest to kill many birds with one stone within that explanation as can be seen here. Quote page 103 of "Learning Perl" 3rd edition:- This program is useful to test out a pattern on some strings and see just what it matches and where: #!/usr/bin/perl while (<>) { # take one input line at a time chomp; if (/YOUR_PATTERN_GOES_HERE/) { print "Matched: $`<$&>$'|\n"; # Mystery code! See the text. } else { print "No match.\n"; } } This pattern test program is written for programmers to use, not endusers, you can tell because it doesn't have any prompts or usage information. Unquote. >From the above, I've learnt :- (1) matching; (2) how to use the default variable $_ ; (3) I've learnt the meaning of $`, $& and $' ; >From the mistake of the original poster, (Just an educated guess) I've also learnt that --> while ( < i am fred flintstone >) <-- reads EACH text as an input line, therefore ----> while ( < i am fred flintstone >) <---- reads 4 input-lines. (I'm glad I've learnt something new ). Therefore what the original poster wants is the following :- while ( < 'i am fred flintstone' >) ## sentence within quotes. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]