John W. Krahn wrote: > Rob Dixon wrote: >> Dr.Ruud wrote: >>> Rob Dixon schreef: >>>> It's equivalent to: >>>> >>>> my $sepchar = ','; >>>> foreach (@_) { >>>> if (/,/) { >>>> $sepchar = ';'; >>>> last; >>>> } >>>> } >>>> >>>> And IMO is much better written that way. >>> TIMTOWTDI. >> But I'm sure you'll agree that some ways are more awkward or obfuscated >> than others. >> >>> Another shortcutting alternative: >>> >>> my $sepchar = ','; >>> for (@_) { $sepchar = ";" and last if /\Q$sepchar/ } >> This relies on ';' being true, and uses 'and' in void context. > > "'and' in void context"? 'and' has two operands so how is it in void > context?
The operands are nothing to do with the context. The compiler doesn't complain about 'and', but for addition: ($sepchar = ";") + last if /\Q$sepchar/; we get Useless use of addition (+) in void context... Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/