My script will ask for an absolute path and give me all the files and Directories and subdirectories and tell me which are files and which are directories. It then gives statistics at the end. Now I want to change it where it will prompt me for an absolute path AND a specific name to search for.

After I put in the name it should list all the files/directories/subdirectories with the name and give the stats at the end.
use File::Find qw(finddepth); #finddepth is a perl reserved word die "GIVE DIRECTORY NAME AS AN ARGUMENT\n" unless @ARGV; *name = *File::Find::name; finddepth \&list, @ARGV; sub print2 { $LINEMAX=2; #SETS HOW MANY LINES OF OUTPUT PER C/R if(++$line > $LINEMAX) { $line=0; getc; } print @_; } if ( !-d ) { print "DIRECTORY NOT FOUND!\n"; exit(0); } else { sub list { if (!-l && -d _) { print2; $i++; print "$name is a DIRECTORY\n"; } else { $j++; print2; print "$name\n"; } } $x=$i+$j; print "\nDIRECTORY COUNT = $i\n"; print "FILE COUNT = $j\n"; print "TOTAL RECORD COUNT = $x\n"; }

My last part of the output (I cut out the first 200 lines of output) for this script is:
/Perl/bin/newr/hh.txt.bak /Perl/bin/newr/scr.pl /Perl/bin/newr/scr.txt /Perl/bin/newr/scr.txt.bak /Perl/bin/newr is a DIRECTORY /Perl/bin is a DIRECTORY DIRECTORY COUNT = 3 FILE COUNT = 209 TOTAL RECORD COUNT = 212

In reply to File Find by oaklander

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.