Perl Question

I was given the attached Perl code to do the following:

1. I have a folder with file names that are codes like 006500000aBcDe.
2. I have a file called Attachments.csv that has a column of codes that will match the file names and a column of meaningful file names such as "proposal for XYZ Corp.doc".

The Perl program is supposed to match the codes and rename the files to have the meaningful file names instead of the codes.  It seemed to work as all the file names got changed and the amount of files in the folder did not change.

However, as I am now doing something else with the renamed files I am finding that some of them somehow did not get renamed properly.  That is, for example, the file was supposed to be changed from the code to "proposal for XYZ Corp, Inc." but it didn't.  It got changed to SOMETHING because the file with the original code name is not there and I didn't lose any files.

So far, it seems like it only happened for files that had a comma in the file name.  I need someone to look at this Perl program and tell me if it would malfunction if the file name had a comma.

Who is Participating?

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

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.

that program would change the name of
1145--Dyno LLC - SafeData
simplest fix is to change
  ($id,$name) = split ',', $line;
  ($id,$name) = split ',', $line,2;

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
moore315Author Commented:
That works - as long as the file name doesn't have more than one comma.  Fortunately for me, none of the file names have more than one comma so I'm good.

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

From novice to tech pro — start learning today.