Question: i want to retrieve a string which falls between two specified strings multiple times in a file

i tried this, but this doesnt work

```
/(?m)"String 1"!.*?"String2":/;

```

> 
> i want every thing that falls between "String 1" and "String 2"
> 
> 
> 

Please help

Answer: 
Assuming your input string is like this

```
$str='String 1GIANT FISHString 2'

```

this will work

```
($wanted)= $str =~ /String 1(.*)String 2/

```

`$wanted` is now "GIANT FISH"

dah..multiline in a file...edit coming up

ok with multiline, assuming input of

```
String 1Line oneString 2
String 1GIANT FISHString 2
String 1String2

```

this will get all the strings

```
(@wanted)= $str =~ /String 1(.*)String 2/g

```

@wanted has three entries

```
('Line one','GIANT FISH','')

```

In the second regex, g for global finds all matches in the string
Below will do:

```
perl -lne 'push @a,/string(.*?)string/g;END{print "@a"}'

```

the two strings are *string* and *string* and anything lying between them will be stroed as an array element.Below is the example that i have tested for the purpose.you can anyhow change the two string to which ever string you need.

tested:

```
> cat temp
string123stringstring234string
string456stringstring789string

> perl -lne 'push @a,/string(.*?)string/g;END{print "@a"}' temp
123 234 456 789

```