Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load many files under Unix

Status
Not open for further replies.

Ultdrake

Programmer
Jul 15, 2002
19
CA
I'm programming a script Perl on Unix and I want to load all *.sta file in a directory. I need help for find a function to read them one after another without know how many or the name of these files...

Thanks
Fred
 
Try something like
Code:
my @files = <dir/*.sta>;
for (@files) {

    open STAFILE, &quot;<$_&quot; or warn(&quot;Couldn't open $_: $!&quot;) && next;
    #do stuff here with <STAFILE>;
    #This prints the filename and its first line
    #my $line = <STAFILE>;
    #print &quot;$_ => $line&quot;;
}

jaa
 
j'ai trouvé la solution, merci pour le coup de main...

opendir(REP, &quot;.&quot;) || die &quot;Probleme $!&quot;;
@files = grep { m/.sta/ } readdir REP;
closedir REP;
print &quot;@files\n&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top