Liam Liam - 3 months ago 6x
Perl Question

Issue moving file

I have the following file_name:

my $filepath = "$common::conf{'admin_dir'}/carts/$paygate::cart_id.csv";

I need to move the file to another directory, but I'm having issues, I'm using the rename function.

rename $filepath, "$common::conf{'admin_dir'}/carts/spent/$paygate::cart_id.csv.bak";

However, it isn't working, I get no errors (using strict), the file remains in the same place though and is not moved.

Could anyone suggest what the issue is?


[The below is not tested]: I ASSUME that file::copy or rename works with the scalar variable's and not support with methods[::].

$common_conf = "$common::conf{'admin_dir'}";
$paygate_cart_id_csv = "$paygate::cart_id.csv";
$paygate_cart_id_csv_bak = "$paygate::cart_id.csv";

my $orgfilepath = "$common_conf/carts/$paygate_cart_id_csv";
my $destfilepath = "$common_conf/carts/spent/$paygate_cart_id_csv_bak";

rename $filepath, $destfilepath;