Hi Monks

This is probably really simple but I cannot for the life of me find any material on this.

I need to write a script that allows someone to enter a reference code when prompted, I already have this but.... I need the script to search a directory full of other directories for a file containing that string which I assume I can use grep for, the difficult bit, for me, is I want to grep the file and then read it into an array like this
pseudo code: #!/usr/bin/perl -w use strict; use warn; my $REF; my @LINES; my $DPT_DIR=/shares/test/PPdir/ print "ENTER REF NUMBER"; chomp($REF = <>); grep "$REF" */*.dpt open my $FH, '<', *.dpt file grep has found chomp(@LINES, $FH); close $FH

Any help would be greatly appreciated.

Thanks

Jim

EDIT: Apologies it has be come apparent to me this isn't very clear, I don't need the list of files in an array but the contents of a single file.
Linux grep: #grep -l ABC123 */*.dpt lloydf/test.dpt <-- I need to read this file.
there are going to be several *.dpt all containing different refs which is why I need to do a grep/find

In reply to Grep file out of directory and read into array by Jalcock501

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.