Hello dk27,

What about some alternatives? Such as File::Find

#!/usr/bin/env perl use warnings; use strict; use File::Find; my $location="$var1/$var2/$var3/"; sub find_ksh { my $F = $File::Find::name; if ($F =~ /ksh$/ ) { print "$F\n"; } } find({ wanted => \&find_ksh, no_chdir=>1}, $location);

Or readdir:

opendir(my $dh, $some_dir) || die "Can't opendir $some_dir: $!"; my @files= map{s/\.[^.]+$//;$_}grep {/\.ksh$/} readdir DIR; closedir $dh;

Both solutions are untested but they should work straight out of the box.

Update: Also if you are running linuxOS or Cygwin terminal:

Update3: as monk haukex pointed out using back ticks is not a good option, read the link on his response bellow why.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $path = shift || '.'; my @files = `find $path -name '*.ksh' -o -name '*.txt'`; chomp @files; print Dumper \@files;

WindowsOS with Cygwin:

my @files = `find $path \( -name '*.ksh' -o -name '*.txt' \)`;

Update2: Similar question with some maybe useful answers combining regex on search see (Re: File::Find find several strings in one directory).

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Use of special character "*" to retrieve the contents by thanos1983
in thread Use of special character "*" to retrieve the contents by dk27

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.