[EMAIL PROTECTED] wrote: > > On 12/08/03 19:33 or thereabouts, John W. Krahn scribbled: > > [EMAIL PROTECTED] wrote: > > > If that is so, what is all that business with the curly braces ? > > > I thought curly braces are supposed to denote code sections ? > > > > Yes, exactly, the curly braces allow the use of a code block > > instead of a simple expression. Having a code block means that you > > can have multiple statements and lexical variables. > > I just read the function "prototype" for grep, and indead they have > grep BLOCK LIST down as a possibility. > This using a BLOCK where I usually expect something like "int x" or > "String name" is sort of funny. > %^) > > Is this fairly normal ? For a function to take a BLOCK as an > "argument" like this ?
Well, it's not un-normal. :-) do, eval, grep, map, sort and sub can all use a block as the first argument. > I'm going to experiment with this, but I take > it the BLOCK has to exit with a true/false value to let grep know > whether to take that list item or not ? That is correct. > But other than that, I guess > I could have print "i'm a grep block" inside there if i wanted ? Yes, and the returned value from print would have determined whether to pass the list element through or not. > > Have you read the documentation for grep in perlfunc.pod? > > Ohh no ! Of course not. as usual I'm in too much of a hurry to learn > everything all at once .... there is only so much time to read > man/info/perldoc pages after all. > %^) > > One last thing. > I noticed some people talking about the use of || vs. or. > I'm sure this is in my Learning Perl book somewhere, but I would have > guessed these were one and the same ... just alternate notations. They do the same thing, however || has the same relative precedence as its C language counterpart while Perl's 'not', 'and', 'or' and 'xor' have lower precedence then all other operators. perldoc perlop John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>