in reply to Re: Pushing to an array
in thread Pushing to an array
For both the below inputs $found is "0",any idea why?Ideally for "inc" $found should match
$mk =./media/common/max/tail/common.mk: $(PROJECT_ROOT)/../../Utils/inc -->$found should be 1
$mk= ./media/common/max/tail/common.mk: $(PROJECT_ROOT)/../../Utils/inC -->$found should be 0#!/usr/bin/perl -w use strict; use warnings; my @folders=("inc","Inc","iNc","incr","src","Src"); my $mk = "./media/common/max/tail/common.mk: $(PROJECT_ROOT)/../../ +Utils/inc"; my $folder_match; my @folder_match; my $found = 0; foreach $folder_match(@folders) { if($mk =~ /^\/\Q$folder_match\E$/i) {# if $mk doesnot match to any+one of @folders,then only push $found = 1; } } print "\nFOUND:$found\n"; if (not $found) { push @folder_match ,$mk; } print "@folder_match\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pushing to an array
by kennethk (Abbot) on Mar 28, 2011 at 15:08 UTC |