>> I am trying to figure out how to use grep in a particular situation. >> The line is: >> >> next unless grep ($fromdevice, @sitenamekeys);
JJ> next unless grep $fromdevice =~ /$_/, @sitenamekeys; >>>>> "JJ" == Jones, Jennifer <jennifer_jo...@bose.com> writes: JJ> I have a question to John's response. The code works if the JJ> condition is met but responds with "Can't "next" outside a loop JJ> block at" when it does not. first off, please don't top post. it makes it hard to follow threads. put your comments below the code you are questioning. in neither example was the outer loop shown. john just followed the example given and fixed it so the grep work. he didn't care about the next command. so for this to be fully correct there should be some loop around the line. but the concept of the way to use grep is valid regardless of the loop being there or not. only the next needs the loop. the reason it worked when the condition passed was that it didn't execute the next. when it fails, it tried to execute the next and failed as it wasn't inside a loop. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/