Re: Opening a directory for writing





-----Original Message-----
From: Mihir Kamdar <kamdarmihir06@xxxxxxxxx>
Sent: Aug 2, 2007 2:26 AM
To: beginners <beginners@xxxxxxxx>
Subject: Opening a directory for writing

Hi,

I am reading all the files in a directory through readdir....Now after
reading each of the file and processing it, I want to write their output one
by one to a different
directory.

Please suggest on how can this be done?


Hi,
you may follow some logic like below:

while (my $file = readdir DIR) {
next if $file =~ /^\.+$/;
my @handled_result = your_handling_routine($file);
open OUT,">","/other/path/$file.out" or die $!;
print OUT @handled_result;
close OUT;
}

you just open a file in other directory with write mode and then print to this file handle.
see:
perldoc -f open
perldoc -f print



--
http://home.arcor.de/jeffpang/
http://home.earthlink.net/~pangj/
.



Relevant Pages

  • Re: Handling locked files with C#
    ... Did you try opening the file with, ... ME> have access to the data acquisition source codes. ... ME> acquisition program locks the files during acquiring and writing the ... ME> can open (for reading) locked files. ...
    (microsoft.public.dotnet.languages.csharp)
  • Positioning a file pointer to the begining of file for writing
    ... Reading fopenmanpages, the only way to do that is opening with ... After opening ... and reading it's content, I'd like to write over the existing content. ... Is there some way to set writing position to the start of file while ...
    (comp.os.linux.development.apps)
  • Re: daemons, sockets and ssh
    ... But does it ever make sense to have 0 open for writing, ... open for reading? ... It's very common. ... opening the terminal on fd 0 read/write and then duping it onto 1 and 2. ...
    (comp.unix.shell)
  • Re: Search script to index dynamic pages
    ... Ahhhh.. ... that's opening 'testtext.txt' for reading. ... Not writing. ...
    (comp.lang.perl.misc)
  • Re: Simultaneously Write to and Read from the same file
    ... opened the file for writing elsewhere, ... should specify FileShare.ReadWrite when opening the file for reading. ...
    (microsoft.public.dotnet.general)