Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Match a chunk

by starbolin (Hermit)
on Jun 12, 2008 at 02:41 UTC ( #691582=note: print w/replies, xml ) Need Help??

in reply to Match a chunk

(1) foreach my $update (@updateloc1){ (2) for my $lin (@texlines){ (3) if ($lin =~ /$update/g){
Line 3 doesn't make sense to me. Why the 'g' option? Do you expect there to be more that one instance of a member of @updateloc1 contained in any given member of @textlines? Also, it would seem, for your dataset, line 3 would always fail as $update would always be a longer string than $lin.

I have to admit I don't understand what you are trying to do. What is your expected output? Is the data always in order like the example? Are there multiple matches in the array?

s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Replies are listed 'Best First'.
Re^2: Match a chunk
by dhasaan (Initiate) on Jun 12, 2008 at 10:06 UTC
    Thanks for the responses, i realize the /g in updateloc1 should not have been added. I need to match each member of texlines exactly to the correct one in updateloc1, the problem occurs when its LakeO's turn and it should come back with the fourth member of updateloc1 (LakeO/stuf), it doesn't, (without /g or \b). What am i doing wrong?
      One problem is that 'LakeO' is a substring of every string in @updateloc1. The regex /LakeO\b/ matches only with 'LakeO/stuf' because the latter string has a forward-slash ('/') in just the right position to match with the \b word-boundary metacharacter in the regex. Why it matches with the use of /g (if, indeed, it does) I will not be able to figure out without the ingestion of a lot more caffeine.

      What is your definition of exact match in the context of the example you have given?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://691582]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-09-27 05:33 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (118 votes). Check out past polls.