nofernandes has asked for the wisdom of the Perl Monks concerning the following question:
I have the following code that provides me an array with, in this case, all the string starting with /* and ending with */ and all the strings starting with // and ending with \n!
my @com=grep defined, <F> =~ m{ ( /\* .*? \*/) | ( \/\/[^\n]*) | " (?: [^"\\]* | \\. )* " | ' (?: [^'\\]* | \\. )* ' | . [^/"']* }xgs; close(F);
This code works fine! But what i want is that instead of getting an array with the strings, i want to get an hash with a the line number of the file where the string was found as key and the string itself as the value!
I can do this easely comparing the returned array with the array of the file, but the problem is that with very large files comparing it makes the program to slow!!!
Does someone have suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex "(un)Knowledge" (loop)
by tye (Sage) on Jul 15, 2003 at 18:02 UTC | |
by nofernandes (Beadle) on Jul 15, 2003 at 18:20 UTC | |
by tye (Sage) on Jul 15, 2003 at 18:27 UTC | |
by nofernandes (Beadle) on Jul 15, 2003 at 18:55 UTC | |
by tye (Sage) on Jul 16, 2003 at 04:20 UTC | |
|
Re: Regex "(un)Knowledge"
by BrowserUk (Patriarch) on Jul 15, 2003 at 17:26 UTC | |
by jmanning2k (Pilgrim) on Jul 15, 2003 at 17:38 UTC | |
by nofernandes (Beadle) on Jul 15, 2003 at 17:43 UTC | |
by BrowserUk (Patriarch) on Jul 15, 2003 at 18:30 UTC | |
by jmanning2k (Pilgrim) on Jul 15, 2003 at 18:39 UTC | |
by nofernandes (Beadle) on Jul 15, 2003 at 17:36 UTC | |
|
Re: Regex "(un)Knowledge"
by nofernandes (Beadle) on Jul 15, 2003 at 19:06 UTC | |
by bm (Hermit) on Jul 16, 2003 at 09:34 UTC |