Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: matching substrings on each line

by Generoso (Parson)
on Oct 08, 2012 at 13:39 UTC ( #997819=note: print w/replies, xml ) Need Help??

in reply to matching substrings on each line

Is this what you are looking for?

#!/usr/bin/perl use strict; use warnings; use v5.10; my @data = <DATA>; foreach (@data) { my ($left, $right)=split' ',$_; my @l=split'(?<=-)',$left; foreach (@l) { say $_." is in ".$right if index($right, $_) > 0; } } __DATA__ a_12_3_5- k_3_4_6-a_12_3_5- q_1_5_7_9- q_1_5_7_9- a_9_4_5-c_3_4_6- c_3_4_6-r_4_5_7- b_1_1_3- v_1_5_7- d_12_4_5-e_4_5_6- g_5_6_7-d_6_8_6- b_1_1_7-f_3_8_7_8-d_4_1_4- d_4_1_5-b_1_1_7-f_3_8_3 b_1_1_7-f_3_8_7_8-d_4_1_4- e_3_3_1-f_3_8_7-f_21_3_1-b_1_1_7-a_1_1_1-


perl "F:\perl_TK\perldb\" Process started >>> a_12_3_5- is in k_3_4_6-a_12_3_5- b_1_1_7- is in d_4_1_5-b_1_1_7-f_3_8_3 b_1_1_7- is in e_3_3_1-f_3_8_7-f_21_3_1-b_1_1_7-a_1_1_1- <<< Process finished. ================ READY ================

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997819]
[jthebarg]: case
[Eily]: :P, the search box is on the top left, or you can use Super Search
[Corion]: jthebarg: There is the switch keyword if you want that, but maybe a dispatch table is closer.
[Corion]: If by "case" you meant "case-insensitive ", see fc, uc and lc and perlop on the /i flag ;)
Corion waves to virtualsue

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2017-09-26 13:41 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (295 votes). Check out past polls.