View Single Post

  #2 (permalink)  
Old 03-10-2006, 03:01 AM
crb3 crb3 is offline
Junior Member
 
Join Date: Mar 2006
Posts: 2
Rep Power: 0
crb3
Default

If by PL you mean Perl, then your IF/THEN logic needs to use Perl syntax, not Bash syntax:

23 FILEPATH = '/trs/wg/'.$ToDate.'/';
24 print "Filepath is $FILEPATH\n";
25 if ( ! -d $FILEPATH ){

27 mkdir $FILEPATH;
28 }

...Use parentheses () instead of brackets [] to enclose your condition-test statement. Use curly-braces {} to enclose your conditionally-executed block of logic, instead of the 'then' and 'fi' keywords. It is safer to conclude every statement in Perl with a semicolon, like in C, than to see which ones you can get away without (the last one in a curly-brace-enclosed block ...but does it stay the last one when you're busy editing and debugging?).

There is a curly-free way to express a simple conditional statement by flipping the order of the test and dependent-logic:

mkdir $FILEPATH unless -d $FILEPATH;

...and I use those only for simple lines I can read at a glance. (Notice that I used the 'unless' keyword, which is logically "if !" but more readable.)

fwiw
cr
Reply With Quote