develooper Front page | perl.perl5.porters | Postings from October 1999

[ID 19991018.001] Perl function"rename oldname, newname" eats network files

From:
D'ANDREA Andy -NUCLEAR
Date:
October 18, 1999 09:48
Subject:
[ID 19991018.001] Perl function"rename oldname, newname" eats network files
Message ID:
1190A430EC98D111837100805F577513027E6343@TORA
This is a bug report for perl from andy.d.andrea@ontariopowergeneration.com,
generated with the help of perlbug 1.26 running under perl 5.00503.

 The "rename oldname, newname" function was being used to rename all files
 in a directory that were named in lowercase or a lower/uppercase mix to all
 uppercase.

 The following code stops when the rename fails the first time. This code is
 being run on a networked NT 4 system. The problem occurs when running the
 script on a network directory containing about 20 files having lower case
 character in their names. It doesn't seem to be a problem if working on a
 local hard disk.

 The file being worked on when rename fails is deleted from the filesystem!

 Please let me know if fixed patch exists.

      Andy D'Andrea

#!/usr/bin/perl
############################################################ toupper
#
#####################################################################
 $cnt = 0;
foreach (<*>) {
   ++$cnt;
   $oldname = $_;
   tr/a-z/A-Z/;
   $newname = $_;
   if( $newname ne $oldname) {
    (-e $oldname) ? print "$oldname -> $newname, ok?": die "$oldname not
there \n";
      $goahead = <STDIN>;
      (rename $oldname, $newname ) ? print " ...done. \n" : die ("whoa, too
fast for the network? $! \n");
   }
}

---
Site configuration information for perl 5.00503:

Summary of my perl5 (5.0 patchlevel 5 subversion 03) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-object
    uname=''
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cl.exe', optimize='-Od -MD -DNDEBUG -TP -GX', gccversion=
    cppflags='-DWIN32'
    ccflags ='-Od -MD -DNDEBUG -TP -GX -DWIN32 -D_CONSOLE -DNO_STRICT
-DHAVE_DES_FCRYPT -DPERL_OBJECT'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -release -machine:x86'
    libpth="C:\Tools\Perl\lib\core" "e:\ntapps\devstudio\vc\lib"
"e:\ntapps\devstudio\vc\mfc\lib" "d:\program files\devstudio\vc\lib"
"d:\program files\devstudio\vc\mfc\lib" "%lib%" 
    libs= oldnames.lib kernel32.lib user32.lib gdi32.lib  winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib  oleaut32.lib netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
PerlCRT.lib
    libc=C:\Tools\Perl\lib\CORE\PerlCRT.lib, so=dll, useshrplib=yes,
libperl=perlcore.lib
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release
-machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl 5.00503:
    C:/Tools/Perl/lib
    C:/Tools/Perl/site/lib
    .

---
Environment for perl 5.00503:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\DevStudio\SharedIDE\BIN;c:\Program
Files\DevStudio\VF\BIN;c:\Program
Files\DevStudio\VC\BIN;C:\Tools\Perl\bin;C:\WINNT\system32;C:\WINNT;F:\ORANT
\BIN;F:\ORAWIN\BIN;F:\SQLW502;C:\PROGRAM FILES\TOOLKIT;c:\PROGRAM
FILES\toolkit;c:\program files\toolkit;F:\CENTURA;C:\Program Files\Mts
    PERL_BADLANG (unset)
    SHELL (unset)

Andy D'Andrea
Associate Engineer
Long-term Waste Management Technology Department
Nuclear Waste Management
* andy.d.andrea@ontariopowergeneration.com
* (416)592-4391


Message from the perl bug squashing team at 'perlbug@perl.org'



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About