in reply to recursive searching in directories

So, do it. File::Find can help with the recursion part.

Which part are you having trouble with? What have you tried?

Replies are listed 'Best First'.
Re^2: recursive searching in directories
by bluetooth (Initiate) on Nov 04, 2011 at 10:51 UTC

    i want to search for a ".c" file or ".h" file in a dir.so, i just took an example. this piece of code is giving unexpected output can you tell where it is going wrong

    $tu ="D:\\vroom\\diags\\in\\frameworks\\my_ip\\shock.h"; print "res:\t$res\n" if $res=$tu=~ m/$.c/g; print "res:\t$res\n" if $mes=$tu=~ m/$.h/g;

    this pice of code returning true for even the first case. it is just searching for "c" not ".c". what should i do to make it search for ".c". where can i check wether i received an answer to my post ?

    $tu ="D:\\vroom\\diags\\in\\frameworks\\my_ip\\shock.h"; if ($mes=$tu=~ m/$.h/g) { open FH, $tu or die "cannot open D:\\vroom\\diags\\in\\frameworks\ +\my_ip\\shock.h :$!\n"; while ( my $line = <FH>) { $line =~ s/\\t/ /g; } close (FH) or die "cannot close D:\\vroom\\diags\\in\\frameworks\\my_i +p\\shock.h:$!\n"; } else { print "out of loop\n"; }

    Above code snippet is not substituting \t(tab) with four space. what should i do achieve it ? How do i get intimated wether i received an answer to my post ?????? THANKS,

      $. is a special variable, and probably doesn't do what you think in the regex. You probably want m/\.c$ (and no g at the end).

      See perlretut for a gentle introduction to regular expressions.