What is wrong with my if perl statement? -


ok driving me crazy!!

looked @ many examples , read on if statements in perl , looks correct me can else spot error?

#start of script #!/usr/bin/perl -w  ########################## #### define variables #### ########################## echo $pwd; maindirectory=$env{home}"/test/"; file='report.txt'; backupdirectory=$env{home}"/test/backup"; number_to_try=0;  ################################## #### check if file exists #### ##################################  filename=$maindirectory$file; echo $filename;  if (-e $filename) {     print "file exists!" } 

error message is:

./perl.pl: line 18: syntax error near unexpected token `{' ./perl.pl: line 18: `if (-e $filename) {' 

anyone have ideas??

all of lines above "if" not valid perl; believe wanted do:

#!/usr/bin/perl use strict; use warnings;  ########################## #### define variables #### ##########################  $maindirectory = "$env{home}/test"; $file = 'report.txt'; $backupdirectory = "$env{home}/test/backup"; $number_to_try = 0;  ################################## #### check if file exists #### ##################################  $filename = "$maindirectory/$file"; print "$filename\n";  if (-e $filename) {         print "file exists!\n"; } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -