Hi Sekhar Reddy, I ran your program and the results are already as you described.

Is there any way that i can give multiple paths like something like ex: myinputpath/*/myfolder/filenames*

Actually I would not adapt this particular kind of program to do this kind of thing automatically. If you really want to then I would look at the examples for readdir, there are ways to specify grep patterns while executing readdir. But personally I would think that the chance that wrong input slips in is too high. Also maybe more flexibility to be able to manipulate the input could be required.

What I would do in this case is create an external configuration file that will contain all the files or folders that the program needs to scan. To obtain these folders I would write a small helper batch-file or perl script that is going to obtain all these folders for me. Example for Windows:

# Note that this is also just a quick scribble and you may need to ada +pt this to your needs # Folders dir /b /s /a:d | perl -ne "print $_ if $_=~/^c:\\myinputpath\\.*?\\myf +older\\.*?$/" > filesconfig.txt # Files dir /b /s | perl -ne "print $_ if $_=~/^c:\\myinputpath\\.*?\\myfolder +\\filenames.*?$/" > foldersconfig.txt

Once I have obtained the config file I can now open it and check if the contents is correct and also I can make enhancements in the sorting order of the folders or files that are being processed. The next thing you can do is adapt your script:

'inputdir=s' => \$inputdir, -> 'configfile=s' => \$configfile,

But again, this is just a quick scribble and there may be better solutions out there:

open( my $cfg, "<", $configfile ) or die "Can't open < $configfile: $! +" ; my @files = () ; while( my $f = <$cfg>) { chomp $f ; # print "f=$f\n" ; opendir(my $dh, $f) or die "ERR: Can't open directory $f: $!"; push @files, map { "$f\\$_" } grep { -f "$f\\$_" } readdir($dh); closedir($dh) ; } foreach ( @files ) { print "$_\n" ; }

In reply to Re^3: Merge and split files based on number of lines by Veltro
in thread Merge and split files based on number of lines by Sekhar Reddy

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.