I have a question to John's response.  

The code works if the condition is met but responds with  "Can't "next" outside 
a loop block at" when it does not.

Can someone please explain why?

Thanks,

Jen
Noah wrote:
> Hi there,

Hello,

> I am trying to figure out how to use grep in a particular situation.
> The line is:
>
> next unless grep ($fromdevice, @sitenamekeys);
>
>
> but I am not quite matching properly.
>
> @sitenamekeys = /ABC DEF GHI/;
>
> and $fromdevice could be something like "device1.abc" or "device2.def"
> basically I am trying to get the grep to identify if the current
> $fromdevice has anything that matching any of the elements in @sitenamekeys
>
> So "device1.abc" or "device2.def" would be a match and therefore would
> continue without next but something like "device1.xyz" would not match
> and therefore next would be executed.

next unless grep $fromdevice =~ /$_/, @sitenamekeys;



John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to