Hi Shlomi, > The problem here that /g confuses Perl and puts it in the \G anchor mode. > Removing both /g fixes the problem. Some other notes: > > 1. You don't really need to say [...]+ inside the regex. [....] here would be > enough.
Unfortunately, removing the /g and the + doesn't help. (Updated code below.) > 2. You may opt to use perldoc -f map instead of foreach here. I don't fully understand map yet. =:\ That's why I'm using foreach. > 3. Since the foreach aliases the variable, you can modify the array in-place. Sorry, but you've lost me here. Could you give an example? Thanks, Marc my $string = 'Off The Menu'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3 and length $word <= 4) and ! ($word =~ m/^[aeiouy]$/i or $word =~ m/^[bcdfghjklmnpqrstvwxz]$/i)) { $word = uc($word); } push @new_words, $word; } $string = "@new_words"; print $string . "\n"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/