|Think about Loose Coupling|
Substring comparisonby schtinkfist893 (Novice)
|on May 01, 2012 at 13:41 UTC||Need Help??|
schtinkfist893 has asked for the
wisdom of the Perl Monks concerning the following question:
Hello- I am fairly new to Perl and have been working on this problem for a couple days now and am a little lost. I need to compare to see if a string in a list is not/or is a substring of an element of another list.
list1 = '123'
list2 = '333 444 555 666'
list21 = '333 444 555 666 123'
Returns should be
list1 =~ list2 = false
list1 =~ list21 = true
and vice versa for !~
Using =~ and !~ m/$string/i has not been helpful. It has been returning false for anything. I have tried to split out the whitespace using split(/\s+/, $list2$i) but I get strange results. I just glanced over 2D arrays and thought that this might be an option. Any guidance would be aprreciated! Thanks!