in reply to Regular expressions across multiple lines
The first assignement seems easy; why check for every char with the dot and not just newline ?
By other hand the description you gave of your code, does not make so much sense to me (and you probably missing use strict; and use warnings; ).perl -E "say q(found ), $count=()=qq(abcdefab\ncdefa\nbcdef) =~ /a\n?b +\n?c/gm, q( [abc] occurences)" found 3 [abc] occurences
while ($line=<inputfile>){chomp $line; $string=$string.$line;}
Infact what i understand is that you are accomulating every new line into $string and attempting the match for every generated string: so for a 100 lines file you are actually examining 5050 lines. this can be a problem.
L*
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regular expressions across multiple lines
by abcd (Novice) on Apr 24, 2016 at 17:44 UTC | |
by Marshall (Canon) on Apr 24, 2016 at 18:01 UTC | |
by abcd (Novice) on Apr 24, 2016 at 18:17 UTC | |
by afoken (Chancellor) on Apr 24, 2016 at 19:23 UTC | |
by Marshall (Canon) on Apr 24, 2016 at 18:41 UTC | |
by Anonymous Monk on Apr 24, 2016 at 18:57 UTC | |
by Anonymous Monk on Apr 24, 2016 at 18:57 UTC | |
by Discipulus (Canon) on Apr 24, 2016 at 19:00 UTC | |
by pryrt (Abbot) on Apr 24, 2016 at 19:33 UTC |