Connecting Tech Pros Worldwide Forums | Help | Site Map

File Program

Newbie
 
Join Date: May 2007
Posts: 6
#1: May 19 '07
Hi,

I am a beginer to perl progmig.
When I run the following program..

Expand|Select|Wrap|Line Numbers
  1. use File::Find;
  2. use File::Stat;
  3. use Time::Local;
  4.  
  5. my $test_data1='X path'; # Some path
  6.  
  7. my @cbr = $test_data1;
  8. foreach $cbr(@cbr) {
  9.     opendir (DIR,$cbr);
  10.     @files = readdir(DIR);
  11.     closedir(DIR);
  12.  
  13.     foreach $file (sort @files) {
  14.         print("$file \n ");
  15.     }
  16. }
  17.  
I am able to print the files present in X path on STDOUT (Command prompt). I am not able to write this OUTPUT to the text file.How can I achive this? And also how can I copy each line of this text fle into excel file.
looking for your response.

Thanks in advance.

Sada

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: May 19 '07

re: File Program


No where in your code are you attempting to write data to a file. Are you confused how to open files for writing or confused why your code does not write anything to a file? If the confusion is on opening a file for writing, this link should help:

http://perldoc.perl.org/perlopentut.html

As far as writing data to an excel file you would probably want to use a module written for that purpose.
Reply