On 1 Jul 1999, Chaim Frenkel wrote: > >>>>> "JC" == John Carter <john@dwaf-hri.pwv.gov.za> writes: > JC> On Wed, 30 Jun 1999, Edward M. Perry wrote: > >> Just for fun, I like: > >> > >> while(<CLONEIDSLIST>) { push(@ids, eval); } > > JC> Yes, its fun, it works, and for the grand prize please explain :- > JC> a) Why does it work? > JC> b) How the blue blazing bliksem's did you find out that it would? > > Think list context, bearwords, and -w. Well I be damned, it _is_ documented. In many odd corners, but it _is_ actually documented... >From "man perldata" A word that has no other interpretation in the grammar will be treated as if it were a quoted string. These are known as "barewords". As with filehandles and labels, a bareword that consists entirely of lowercase letters risks conflict with future reserved words, and if you use the -w switch, Perl will warn you about any such words. Some people may wish to outlaw barewords entirely. I would heartily second that last sentence! >From "man perlop" on the comma operator... In a list context, it's just the list argument separator, and inserts both its arguments into the list. Eval working on $_ is standard behaviour for nearly all things in "man perlfunc", so no suprise there. > But I can't get it to work. @ids ends up empty. That's strange, running the following on perl, version 5.004_04 built for i386-linux works fine... perl -we 'while(<STDIN>) { push(@ids, eval);}print join(":",@ids),"\n";' a,b,c,d Unquoted string "a" may clash with future reserved word at (eval 1) line 1, <STDIN> chunk 1. Unquoted string "b" may clash with future reserved word at (eval 1) line 1, <STDIN> chunk 1. Unquoted string "c" may clash with future reserved word at (eval 1) line 1, <STDIN> chunk 1. Unquoted string "d" may clash with future reserved word at (eval 1) line 1, <STDIN> chunk 1. <cntrl-d> a:b:c:d John Carter EMail: ece@dwaf-hri.pwv.gov.za Telephone : 27-12-808-0374x194 Fax:- 27-12-808-0338 <http://www.geocities.com/SoHo/Cafe/5947> or <http://iwqs.pwv.gov.za> Despite all cheerful predictions, I'm moving seamlessly from being a confused and angry young man to becoming an angry and confused old man. ==== Want to unsubscribe from Fun With Perl? ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org