Re: String in Array

2014-02-20 Thread Peter Gordon
On Thu, 20 Feb 2014 15:05:42 -0600, Matt wrote: >my @alarm = ("xyz", "abc"); >>my $name = "ab"; >>unless (grep {/$name/} @alarm) { # do this } >If I set 'my $name = "abc";' it seems to match.  But I want to match >on "ab" as well.   It appears to do this already.   #!/usr/bin/perl -w use 5.14.0;

Re: String in Array

2014-02-20 Thread Matt
> Having trouble making this work. > > my @alarm = ("xyz", "abc"); > my $name = "ab"; > unless (grep {/$name/} @alarm) { # do this } > > Since "ab" is contained in the array I want it to NOT 'do this'. What > have I got wrong? If I set 'my $name = "abc";' it seems to match. But I want to match

Re: String in Array

2014-02-20 Thread Uri Guttman
On 02/20/2014 02:04 PM, Matt wrote: Having trouble making this work. my @alarm = ("xyz", "abc"); my $name = "ab"; unless (grep {/$name/} @alarm) { # do this } Since "ab" is contained in the array I want it to NOT 'do this'. What have I got wrong? can you show this not working? it looks good

Re: String in Array

2014-02-20 Thread Peter Gordon
On Thu, 20 Feb 2014 13:04:56 -0600, Matt wrote: >Having trouble making this work. > >my @alarm = ("xyz", "abc"); >my $name = "ab"; >unless (grep {/$name/} @alarm) { # do this } > >Since "ab" is contained in the array I want it to NOT 'do this'. >What >have I got wrong? > Use word boundaries #!/us

String in Array

2014-02-20 Thread Matt
Having trouble making this work. my @alarm = ("xyz", "abc"); my $name = "ab"; unless (grep {/$name/} @alarm) { # do this } Since "ab" is contained in the array I want it to NOT 'do this'. What have I got wrong? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,