[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] for loop quickie




after:

   for (@row) {
      s/[^ -~]//g;
      s/\|/:/g;
   }

Beautiful. Getting out of the C mindset of keeping a loop index is one of the big steps into Perl mastery.

Note that in this example, there's an implicit $_ being used as the loop variable. You can also make it explicit:

for my $entry (@row) {
    $entry =~ s/...../;
}

In this case, although it looks like $entry is a temporary variable, and that changes to $entry will get thrown away, that's not the case. $entry is an alias to the iterated variable.

xoa


--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance