T
therocket79
Hi,
I have a question about the following line of code:
$new_file =~ s/^$from_dir/$to_dir/;
I have 2 variables $from_dir and $to_dir which are different directory
path names. I also have the $new_file variable which is the full path
of a file. I am trying to substitute the first part of the file path
($from_dir) with a new file path ($to_dir), following on from this I
copy the original file to the new location.
An example:
$new_file = C:/directory1/file.txt
$from_dir = C:/directory1
$to_dir = C:/directory2
I would like the result of the substitution to be $new_file =
C:/directory2/file.txt, so I can then copy C:/directory1/file.txt to
C:/directory2/file.txt
However, this seems to work on some machines but fail on others. The
reason being the substitution doesn't seem to take place correctly and
I end up trying to copy something to the same location. Can anyone
help with why this is happening?
I have a question about the following line of code:
$new_file =~ s/^$from_dir/$to_dir/;
I have 2 variables $from_dir and $to_dir which are different directory
path names. I also have the $new_file variable which is the full path
of a file. I am trying to substitute the first part of the file path
($from_dir) with a new file path ($to_dir), following on from this I
copy the original file to the new location.
An example:
$new_file = C:/directory1/file.txt
$from_dir = C:/directory1
$to_dir = C:/directory2
I would like the result of the substitution to be $new_file =
C:/directory2/file.txt, so I can then copy C:/directory1/file.txt to
C:/directory2/file.txt
However, this seems to work on some machines but fail on others. The
reason being the substitution doesn't seem to take place correctly and
I end up trying to copy something to the same location. Can anyone
help with why this is happening?