make multiple copies of a file with slightly different names

I'm trying to write a Perl script to name cemetery files in an organized manner.  The files are for lots in section B of the cemetery.  Each lot is designated by a 3 digit number and so I'm trying to name them:
Blot043, Blot100, etc.  
My script doesn't work.  What wrong with it?
dwcroninAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FishMongerCommented:
Saying your script doesn't work is a very poor problem description.

In what way is it failing?

How do the results differ from what you expect?

What errors and warnings are you receiving?

You need to show us the script.
0
dwcroninAuthor Commented:
You're.  I thought that the script was attached.  It's very short and I was hoping it would be apparent.
Here are the missing parts:

-------------------------script-------------
foreach$lotnumber (qw/ 043 044 046 047 049 050 053 055 056 057 058 061 062 063 064 066 067 068 069 070 071 072 073 074 075 076 077 078 080 081 082 083 084 085 086 087 088 090 091 092 094 095 97 097 098 099 100 101 102 103 104 105 106 107 108 109 112 113 114 115 116 117 119 120 121 123 124 127 128 129 130 131 132 133 138 139 140 141 142 143 144 145 146 147 148 149 150 152 153 154 156 158 159 160 161 162 164 165 166 167 168 169 170 172 173 174 175/){
copy gridlots Blot$lotnumber}; #copy gridlot for each blot
----------------------------------------------------------------------------------
perl makelot.pl
Can't locate object method "Blot" via package "043" (perhaps you forgot to load "043"?) at makelots.pl line 2.
0
FishMongerCommented:
The copy statement is missing a comma between the source and destination and you're missing the quotes around the string(s).

Putting all of the numbers in the foreach initialization like that is very messy and more difficult to maintain.  Put those numbers in an array and use that array in the loop initialization.

Do you have warnings and strict enabled?  I.e., do you have these 2 use statements near the top of the script?
use warnings;
use strict;

Open in new window


If not, you should add them and fix the problems they point out.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

dwcroninAuthor Commented:
I'm sorry but I haven't had time to make this an array.  That sounds much better, but I don't know the syntax of an array.  it is now:
-----------------------------start of script---------------------------------------------------------------------
use warnings;
use strict;
foreach$lotnumber (qw/ "043 044 046 047 049 050 053 055 056 057 058 061 062 063 064 066 067 068 069 070 071 072 073 074 075 076 077 078 080 081 082 083 084 085 086 087 088 090 091 092 094 095 97 097 098 099 100 101 102 103 104 105 106 107 108 109 112 113 114 115 116 117 119 120 121 12off3 124 127 128 129 130 131 132 133 138 139 140 141 142 143 144 145 146 147 148 149 150 152 153 154 156 158 159 160 161 162 164 165 166 167 168 169 170 172 173 174 175"/){
copy gridlots.svg, Blot$lotnumber.svg}; #copy gridlot for each blot
-------------------------------------------------end of script-------------------------------------------------
------------------  start of errors--------------------
perl makelots.pl
Global symbol "$lotnumber" requires explicit package name (did you forget to declare "my $lotnumber"?) at makelots.pl line 3.
Global symbol "$lotnumber" requires explicit package name (did you forget to declare "my $lotnumber"?) at makelots.pl line 4.
Bareword "svg" not allowed while "strict subs" in use at makelots.pl line 4.
Bareword "svg" not allowed while "strict subs" in use at makelots.pl line 4.
Execution of makelots.pl aborted due to compilation errors.

----------------- end of errors----------------------------
0
FishMongerCommented:
The strict pragma requires you to declare your vars, which is done with the my keyword..  You also forgot to add the quotes around the filenames in the copy statement.  Also, please use the CODE tags around your code.

Here's the corrected version  (excluding the addition of the array).
use warnings;
use strict;
use File::Copy;

foreach my $lotnumber (qw/043 044 046 047 049 050 053 055 056 057 058 061 062 063 064 066 067 068 069 070 071 072 073 074 075 076 077 078 080 081 082 083 084 085 086 087 088 090 091 092 094 095 97 097 098 099 100 101 102 103 104 105 106 107 108 109 112 113 114 115 116 117 119 120 121 12off3 124 127 128 129 130 131 132 133 138 139 140 141 142 143 144 145 146 147 148 149 150 152 153 154 156 158 159 160 161 162 164 165 166 167 168 169 170 172 173 174 175/) {
    copy("gridlots.svg", "Blot$lotnumber.svg");
} #copy gridlot for each blot

Open in new window

0
dwcroninAuthor Commented:
I changed the code in the way I hope is more manageable by "trying" to make this an array.  The numbering of the lots seems foolish but I talked to the gravedigger who has done this job for 40+ years and he shrugged and had no explanation either.  Anyway, Perl says "illegal octal digit 8 or 9" in many lines of my file.  Now this way doesn't work either...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.