Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't modify subtraction (-) in scalar assingment

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
Good afternoon,

I am working a script where it goes into a specific directory and delete files ending .edi. Then within the same script goes into another directory/folder and delete different files. However I when I run the script on MSDos I would get the error message of "Can't modify subtraction (-) in scalar assignment at delete_old_files.pl line 29, near ""/outbound/Perl/ISD-EDI/TS210IB-BK";"

Below is what I have for the script:


use File::Copy;
$dir_210IB = "/outbound/Perl/ISD-EDI/TS210IB";
$retention_period_210IB = "3";
## OPEN AND READ THE DIRECTORY
opendir (DIR, "$dir_210IB/");
@FILES = grep(/a*.edi/,readdir(DIR));
closedir (DIR);
## DELETE THE .EDI FILES THAT ARE OLDER THAN X NUMBER OF DAYS
foreach $FILES (@FILES) {
if (-M "$dir_210IB/$FILES" > $retention_period_210IB) {
print "$FILES\n";
unlink("$dir_210IB/$FILES");
}
}

## DELETE IB210-BK
$dir_210IB-BK = "/outbound/Perl/ISD-EDI/TS210IB-BK";
$retention_period_210IB-BK = "3";
## OPEN AND READ THE DIRECTORY
opendir (DIR, "$dir_210IB-BK/");
@FILES = grep(/a*.edi/,readdir(DIR));
closedir (DIR);
## DELETE THE .EDI FILES THAT ARE OLDER THAN X NUMBER OF DAYS
foreach $FILES (@FILES) {
if (-M "$dir_210IB-BK/$FILES" > $retention_period_210IB-BK) {
print "$FILES\n";
unlink("$dir_210IB-BK/$FILES");
}
}
 
I don't think $dir_210IB-BK is a valid variable name.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Tom has it
Code:
$dir_210IB-BK="Fred";
does indeed chuck a wobbly

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top