in reply to Grep failing
Based off your very limited description, I'm surmising that $mk contains a return delimited list of folders and you're trying to determine if $folder is present.
As davido already pointed out, grep is not what you need for this because that is meant only for array operations. If you're just working on a scalar, you can do the test directly. Secondly, based off your regex, I suspect your problem is you're not using the 'm' modifier which would make it so ^ and $ matched the beginning and end of any line within the text, not just the start and end of the string.
Here's an example that does match like you want
my $mk = <<'END_LIST'; /foo/bar /foo/baz /eep/foo/bar /epp/foo/baz /biz /baz/foo/bar END_LIST my $folder = '/foo/baz'; my $folder_present = $mk =~ /^\Q$folder\E$/im; print "$folder_present"; # Prints 1
- Miller
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Grep failing
by Anonymous Monk on Mar 21, 2011 at 23:55 UTC | |
by wind (Priest) on Mar 22, 2011 at 01:13 UTC |