in reply to Re^2: Braino - why is this not working?
in thread Braino - why is this not working?

Between the time I logged off yesterday and logged back in today, the discussion has extended considerably and you appear to have your answer.

In general, I tend to use a lexical variable in for loops and the block form of map, grep and similar constructs.

for my $list_element (@list) { # use $list_element here } map { ... } @list; grep { ... } @list; sort { ... } @list;

(for and foreach are synonymous, in case you didn't know)

This generally avoids any confusion over what $_ refers to.

Perl 5.10 introduced a new lexically scoped $_ (that's in addition to the current globally scoped $_) so there's even more chance of confusion.

Hoping your head isn't hurting too much and the wall doesn't need fixing. :-)

-- Ken