My question is the same question as How to make re.search or re.match on the entire file without reading it all in memory? but using perl instead of python
Question: I want to be able to run a regular expression for the entire file, but I would like to be able to not read the entire file in memory at once, how can I work with fairly large files in the future, is there a way to do this? Thanks!
Explanation: I cannot read line by line because it can span multiple lines.
Why am I using perl instead of python? I am having problems with python regex that I need to switch to perl. I would install https://pypi.python.org/pypi/regex , but I can’t, since my workstation, of course, doesn’t allow write access to its python installation directory, and I would rather avoid slow electronic mail and email using IT to install them for me and / or deal with further permissions :)
EDIT: examples of templates I'm looking for
assign signal0 = (cond1) ? val1 : (cond2) ? val2 : val3; assign signal1[15:0] = {input1[7:0], input2[7:0]}; assign signal2[34:0] = { 4'b0, subsig0[3:0], subsig1, subsig2, subsig3[18:2], subsig4[5:0] };
I am looking for patterns like the above, i.e. assignment of a variable until I see a semicolon. The regular expression will match any of the above, since I don't know if the pattern is multi-line or not. Perhaps something similar to /assign\s+\w+\s+=\s+[^;];/m , that is, until I get a semicolon
EDIT2: From the answers given (thanks!), It seems that decomposing a template into the start, middle, and end sections might be the best strategy, for example. using the range operator, as suggested by some.