in reply to Re^13: search and replace strings in different files in a directory
in thread search and replace strings in different files in a directory

Dear Monks

Sorry for pestering you once again with my noob questions. I changed the script according to your recommendations. So far no more BOM errors and everything seems to be working as planned.

However, I got the following error message the meaning of which I am not quite sure of. Maybe one of you could shed some light on this (I used Carp::Always, as one of you suggested). I had to anonymise the code for I guess you know why....

Error opendir on 'Z:/123/xyz/xyz/xyz_xyz_xyz_/01_abc': No such file or directory at C:/strawberry/perl/site/lib/Path/Tiny.pm +line 1490. Path::Tiny::Error::throw("Path::Tiny::Error", "opendir", "Z:/2014/xyz/ +xyz/xyz_xyz_xyz_/01_abc"") called at C:/strawberry/perl/site/lib/Path/Tiny.pm line 126 Path::Tiny::_throw(Path::Tiny=ARRAY(0x2774f74), "opendir") called at C +:/strawberry/perl/site/lib/Path/Tiny.pm line 532 Path::Tiny::children(Path::Tiny=ARRAY(0x2774f74), qr(\.xml$)u) called +at script.pl line 59 main::RetrieveAndBackupXML("Z:/123/xyz/xyz/xyz_xyz_xyz_/01_abc\\0"...) + called at script.pl line 31 main::Main() called at script.pl line 20

In my opinion, the error is telling me that neither the folder nor the files exist (well, you cannot access the files if you cannot access the folder.

Question is why is the programm throwing this error message, the folders do exist as indicated by the path names I am reading out.

Is it problem if I access a network-drive? Would that be another building block that would bloat the script and provide with me with yet another topic to read about?

A penny for your thoughts.

Kind regards

C
  • Comment on Re^14: search and replace strings in different files in a directory
  • Download Code

Replies are listed 'Best First'.
Re^15: search and replace strings in different files in a directory
by Anonymous Monk on Sep 03, 2014 at 01:19 UTC

    Hmm, you say it exists as a directory, does the path contain any unicode codepoints ? What do you get with this program

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; use Win32; use Win32::Unicode qw/ statW /; my $path = 'Z:/123/xyz/xyz/xyz_xyz_xyz_/01_abc'; dd( $path ); dd({ -ansi, Win32::GetANSIPathName( $path ) }); dd({ -full, scalar Win32::GetFullPathName( $path ) }); dd({ -short, Win32::GetShortPathName( $path ) }); dd( statW( $path ) ); __END__

      Dear Anonymous Monk

      There might be some umlauts in some of the path names. Would that trigger the alarm?

      The initial purpose of the file (before it becam a rather huge project for a novice like me) was to do the following:

      read the path in the text-file provided by user

      go to each directory specified by the path name

      Look for any xml-files and open each one individually

      in each xml-file replace certain strings

      create a backup of the xml(s)

      close the file(s)

      close the directory

      Hope that helps (it did for me to get an initial idea what I was going to do step by step)

      Looking forward to your reply. Thanks for your help

      Kind regards

      C.

        There might be some umlauts in some of the path names. Would that trigger the alarm?

        No alarm, but you might not be able to open the files without help of GetShortPathName or openW :) although you probably might open "da-MötleyCrüe", it depends

        If you make sub ddiagnostic out of what I posted, you can use  ddiagnostic( $path ); to see if this is an issue

        This is one of the reasons for the subs subs subs subs. You can write/debug using simple ascii test filenames ... figure out the program logic get it 99% there, then throw in some unicode filenames and only change a few subs

        Or maybe even change no subs, maybe :)( Re^3: Trouble with File::Find::Rule (win32 unicode overload file test operators) )