Hello Monks,

I have 26 cisco switch dumps. These are large files with close to a million files each. I tried opening individual files and reading them. But it is extremely slow. Ended up using Unix grep instead, which is fast.

Here is my code.

 my $hba_alias = `grep $host_hi $switchdir/*.swc|grep ":  device-alias"|head -1`;`

At some places I am grepping individual files like this

 my $hba_swport = `grep $hba_wwn $switchdir/$switchfqdn|grep "^fc"|head -1`

I want to grep without opening the files which is lot faster and also I can get away from using unix commands. Any ideas how can I accomplish this ?

TIA

-Shynee


In reply to grep equivalent in perl by shynee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.