in reply to Re^4: Manipulating directory paths
in thread Manipulating directory paths
"If $ver_name is present" is meaningless, since I'm pretty sure you don't want to check if the variable exists. I'm guessing from your code that you want to check if the file named by $ver_name exists (which -f would do), but it could mean many other things.
You're using our. Don't use globals.
Don't use the conditional operator (?:) to conditionally execute entire statements. Using that operator for anything but the simplest expression usually makes it unreadable. It really works best when the returned value is actually used.
The output you said you get is not the output the code produces.
It produces '/home/user/phase/dir1abinitio/run'
and not '/home/user/phase/dir1//abinitio/run'
You're missing a / because you removed the / before log without replacing it.
This should have been easy for you to find out by comparing the one that worked and the one that didn't.
my $replace = (-f $ver_name ? "/$ver_name" : '') . '/abinitio/run'; (my $graph_dir = $before) =~ s{ /log/ .* \z }{$replace}xs;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Manipulating directory paths
by pp (Novice) on Sep 13, 2007 at 18:14 UTC | |
by ikegami (Patriarch) on Sep 13, 2007 at 18:47 UTC | |
by pp (Novice) on Sep 13, 2007 at 19:28 UTC | |
by ikegami (Patriarch) on Sep 13, 2007 at 20:13 UTC | |
by pp (Novice) on Sep 13, 2007 at 20:33 UTC | |
|