How do I find the compilation error in this Perl statement?
I have this code:
my $orig_file_size = -s $file ;
Is throwing an error:
syntax error at ftp_4 line 33, near "$orig_file_size)"
Execution of ftp_4 aborted due to compilation errors.
Here is some more code:
my $host ='hpp411';开发者_高级运维
my $user ='sonalg';
my $pw ='Unix11!';
my $file ='ftp_example.p_1';
my $path ='/enbusers3.p411/vdx/af/sonalg/oldproj';
my $orig_file_size = -s $file;
my $ftp = Net::FTP->new($host, Debug => 1)
or die "Could not connect to '$host': $@";
Check your source
According to the error message, you have a closing bracket after the variable like this:
my $orig_file_size) = -s $file ;
If so, just remove it.
The nothing wrong with that statement. The problem is probably earlier in the file.
It's tempting to say the problem is with the previous line but given the difficulty in parsing Perl the problem could be anywhere higher up the file. The first things to look for are strings which haven't been closed properly and lines missing their terminating semicolon.
Your error message (but not your code as shown) suggests you have a stray parenthesis after $orig_file_size.
Do you actually have:
my $orig_file_size) = -s $file ;
If so, try:
my $orig_file_size = -s $file ;
or
my($orig_file_size) = -s $file ;
精彩评论