I tried the options that you have suggested but it seems to work in one case and not in the other.
I want to be able to replace everything from the log directory onwards with certain other paths as I have explained below.
I have a conditional statement in the code where I am saying that if $ver_name is present then replace everything from the log directory onwards with $ver_name/abinitio/run into the variable graph_dir and if $ver_name is not present then replace with abinitio/run into the graph_dir.
I have the following code:
( ! -z $ver_name ) ? (our $graph_dir = $before1) =~s{ /log .* \z}{/$ve
+r_name/abinitio/run}xms :(our $grap
h_dir=$before2) =~s{ /log/ .* \z}{abinitio/run}xms;
CASE 1:
my $before1 =/home/user/phase/dir1/log/
and when passed through the conditional statement I want to derive the below graph_dir
graph_dir= /home/user/phase/dir1/2.11/ abinitio/run
CASE 2:
my $before2 = /home/user/phase/dir1/log/Illinois/
and when passed through the conditional statement I want to derive the below graph_dir
graph_dir =/home/user/phase/dir1/abinitio/run/
In my output when I see Case1 seems to work fine but when in Case 2 the value I am deriving for graph_dir is /home/user/phase/dir1//abinitio/run
Can you please point out where I am going wrong with this?
Thank you. |