|Don't ask to ask, just ask|
Re: appending file nameby marinersk (Priest)
|on Jul 17, 2013 at 16:07 UTC||Need Help??|
Summary of Problem: You are creating a dynamic array instead of contatenating strings.
Simply to get it to run, I adjusted your code as follows:
Which produced the following:
Interestingly, I was expecting it to create 3.txt, but it merely created .txt. I will have to look into why; the clue is in the warning messages, I'm sure.
Anyway, I changed one line:
And got the following results:
This seems to be closer to what you were trying to accomplish.
So, some observations:
1) Simple string contantenation in Perl is done using the . operator.
2) You might benefit from thinking in terms of using reciprocal functions. You used split to break apart the name; it would be prudent to use join to put it back together. split and join are essentially reciprocal functions.
3) There are modules which do a pretty good job of handling most filename related functions, and often honor the rules and trends of the OS you're running on, but this looks like a learn-Perl kind of exercise so there is much to be gained from learning how to do the basic work by hand. Just be aware that modules, especially ones published to CPAN, usually handle a lot of the corner cases you will overlook, so learning to leverage the publicly-shared work of others is a valuable skill in this profession.