Title question: "grep equivalent in Perl"?
Answer:
grep
But that's not the same as the key question in your narrative; namely "how do I ' grep without opening the files...'?"
At least as I understand it, that translates to "I want to read something (inside) files without opening the file."
Better to try for an answer to that at Magic_Monks or Sorcerers,Inc.
So, looking for another approach involving Perl, and assuming you meant -- in your second sentence -- either (less likely:) 'these are close to a million large files' or (more likely, I guess1) 'These files contain close to a million lines each':
- Are you opening any of these files more than once? If so, refactoring to avoid redundant opens might be helpful
- Are your pipes setting your system to thrashing the swap disc? If so, do you have enough RAM to hold an entire file; can you refactor to use that capability?
1 Making us guess what you mean can be a matter of ignorance of a subject matter, sloppy writing or sloppy thought. If it's not the first of those, see
I know what I mean. Why don't you?; in fact, see it anyway.
See also:
On asking for help and
How do I post a question effectively?.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.