I am getting the following error when I run the code,strangely if set the variable as $8k_m,if I remove the number "8" and change the variable as "$k_m",I see the error is gone,what am I doing wrong?
Error:- Bareword found where operator expected at ftp.pl line 15, near "$8k_m" (Missing operator before k_m?) Can't use global $8 in "my" at ftp.pl line 15, near "my $8" syntax error at ftp.pl line 15, near "$8k_m" Execution of ftp.pl aborted due to compilation errors. #!/usr/bin/perl -w use strict; use warnings; use Cwd qw(getcwd); use File::Copy; use File::Find; use Net::Telnet; use Net::FTP; use Getopt::Std; my %options=(); getopt("b",\%options); my $cwd = getcwd; my $8k_m= $options{b}; my ($input,$output); my %files = map {$_ => 1} qw(amss.mbn dsp.elf); find(sub { copy($File::Find::name, $cwd) or die "Can't cp $File::Find::name: +$!" if (delete $files{$_}); }, $8k_m); print "\nFTP.ing Modem and DSP images...\n"; my $ftp = Net::FTP->new("10.42.9.119", Debug => 0) or die "Cannot connect to the target: $@"; $ftp->login("user","user") or die "Cannot login ", $ftp->message; $ftp->cwd("/mnt/data") or die "Cannot change working directory ", $ftp->message; $ftp->binary(); $ftp->put("data.mbn") or die "put failed ", $ftp->message;; $ftp->put("file.elf") or die "put failed ", $ftp->message; $ftp->quit();
In reply to Error when adding a number to a variable by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |