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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to append to a text file from an array

Status
Not open for further replies.

fyyap

Programmer
Oct 29, 2001
9
SG
Hi,

I'm a new learner abt Perl. Would like to know that how can I write and append to a text file from an array. Each entry will be seperate by next line (\n). Please help. Thanx :)
 
open FH, ">>mytext.txt"; #>> meaning append
foreach $element (@myarray) {
print FH "$element";
}
close FH
 
Here are the requirements step:
- How to write all the file name with prefix AAA to file list
- append the filename to an array.

e.g

F_PREFIX = "AAA";
F_SUFFIX = "ddd";
test_list = "test_list";

ls $F_PREFIX*[0-9]*$F_SUFFIX > $test_list
for $filename in `cat $test_list`
do
@file_list=(@filename);
print "@file_list \n";
done


Thanks in advance.

/kl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top