John W. Krahn wrote:
>
> I think you mean:
>
> $files = join ' and ', (join ', ', @files), $_ for pop @files;
>
> But that will prepend ' and ' if there is only one file name in
> @files.
Thanks.
> It also doesn't seem right to use a loop just to force 'pop
> @files' to evaluate first.
It's only a 'loop' in the same way that 'map' is. I was using it rather
to
avoid an explicit temporary variable.
perldoc perlsyn:
A common idiom for a "switch" statement is to use "foreach"'s
aliasing
to make a temporary assignment to "$_" for convenient matching:
SWITCH: for ($where) {
/In Card Names/ && do { push @flags, '-e';
last; };
/Anywhere/ && do { push @flags, '-h';
last; };
/In Rulings/ && do {
last; };
die "unknown value for form variable where:
`$where'";
}
>> An interesting point here. I don't think there's a way to persuade
>> loops to return a value.
>
> I think you mean "I don't think there's a way to persuade loops to
> return a scalar." and no, you have to use join/concatenation to
> transform a list/array to a scalar.
I don't know of a way for them to return lists either. As far as I can
tell a 'for/foreach' can't be used as an expression at all. I withhold
judgement on 'while', but I guess it's the same.
> Don't forget -- TMTOWTDI
Amen to that.
/R
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]