ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This seems to be an weird error to me although it could be a problem where I am just missing something. Below I have the error and the piece of code it is talking about. Can someone see what I did wrong?
The error is:
Can't modify subtraction (-) in scalar assignment at ./<script name> line 32, near "};"
Execution of ./<script name> aborted due to compilation errors.
The code is :
$f = "PCOUNTER_" . $yr . "_$mo.LOG";
$h = "Print Charges for $mon[$mo], $yr";
print "$h\nFilename: $f\n";
cp $home/smb/testing/DATA/$f /logs-testing-Staff/
********************* area where the error seems to appear **********
$home = $ENV{"HOME"};
unless ($home) {
$home = "/home/print";
}
**************** end area ***************
well no, i've no idea if that's meant to work or not, i know nothing about your filesystem. if that's *ALL* the code you have then $home hasn't been initialized yet maybe?
copy("$home/smb/testing/DATA/$f", "$home/logs-testing-Staff/") or die "File cannot be copied.";
I get:
File cannot be copied. at ./<script name> line 27.
I also had to put in "use File::Copy;"
any idea?
The $HOME variable is defined within your shell. You'll either have to use environment variables within your Perl code, define it on the command line, or hard-code it.
Export (or make sure it's set), whatever environment variable you want. Then, your Perl script can use the %ENV hash to read these in. If you've exported FOO="/tmp/test", $ENV{FOO} will have the value "/tmp/test" for your program later on down.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.