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

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.
  • Comment on Re^16: search and replace strings in different files in a directory

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

    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) )

      Dear Anonymous Monk

      Thanks a mil for your help.

      I used your code to check and found out that umlauts were the culprits

      I created a test folder with test file and ran the code. To my surprise I got new error messages (cf. list below), which have not yet appeared... As you can imagine, the source files remained untouched and no back-up files were created

      Use of uninitialized value $dst in rename at C:/strawberry/perl/site/l +ib/Path/Tiny.pm line 1004. Path::Tiny::move(Path::Tiny=ARRAY(0x267ea6c), undef) called at hor +nbach_entities_20140902.pl line 68 main::Replace(Path::Tiny=ARRAY(0x267ea6c), "T:/2014/F.../C.../a.xm +l-2014-09-03.bak") called at script.pl line 59 main::RetrieveAndBackupXML("t:/F.../C.../\") called at script.pl l +ine 29 main::Main() called at script.pl line 18 Use of uninitialized value $dst in concatenation (.) or string at C:/s +trawberry/perl/site/lib/Path/Tiny.pm line 1004. Path::Tiny::move(Path::Tiny=ARRAY(0x267ea6c), undef) called at scr +ipt.pl line 68 main::Replace(Path::Tiny=ARRAY(0x267ea6c), "T://F.../C.../a.xml-20 +14-09-03.bak") called at hornbach_entities_20140902.pl line 59 main::RetrieveAndBackupXML("t:\\2014\\F...\\C...\\") called at hor +nbach_entities_20140902.pl line 29 main::Main() called at hornbach_entities_20140902.pl line 18 Error rename on 'T:/2014/F.../C...//a.xml' -> ''': at C:/strawberry/p +erl/site/lib/Path/Tiny.pm line 1490. Path::Tiny::Error::throw("Path::Tiny::Error", "rename", "T::/2014/ +F.../C.../a.xml' -> ''", "") called at C:/strawberry/perl/site/lib/Pa +th/Tiny.pm line 126 Path::Tiny::_throw(Path::Tiny=ARRAY(0x267ea6c), "rename", "T:/2014 +/F.../C.../a.xml' -> ''") called at C:/strawberry/perl/site/lib/Path/ +Tiny.pm line 1004 Path::Tiny::move(Path::Tiny=ARRAY(0x267ea6c), undef) called at scr +ipt.pl line 68 main::Replace(Path::Tiny=ARRAY(0x267ea6c)...[...]

      I seem unable to figure what the exact meaning of the error is, I reckon it must be something in the xml-files,

      I am really sorry for all these questions, however it is a good way to learn things.

      Thanks a mil for your support

      Kind regards

      C.

        It says you're giving move undef, I don't know why you're doing that, I can't see your code