Home: Perl Programming Help: Intermediate:
Comparison and editing files script

New User

Jan 11, 2012, 2:58 AM

Views: 1444
Comparison and editing files script


I have a backup solution (TSM) which will run every weekend a script. This script will save a list of VM and VM are four lists (one week). For now my VM lists are filled by hand but I want to write a script that automatically fill in these files while balancing the load (load space, I mean GB of VMDK to save each week) at the option of additions and deletions VM.

At the moment I thought of something like this:

The script will take as parameters:

- A file containing a list of all VMs on the present below a week earlier
- The quantity of GB VMDK lists for each of the four (4 files as parameters)

The script will:

- Get the current list of all VM
- If there is no difference stop treatment
- If there is a difference, he will find:
* If it is a VM within it will remove it from the list and change the total size in GB of VMDK from its list
* If it is a VM in addition, it will add the machine name to the list including the smallest storage space to save
- If there was a change it will send an email
- If there was a change, it will update the list of total VM it will take a point of comparison when the next time the script

The list of VM in 4 files are in this form:


So the script should be able to delete the name of a VM and the comma that follows, and if such a VM to add it should add ",VMname".

In addition the command to list VM is PowerShell, right after there is no worries on that side.

Well, I'm not sure where to see, I do not know how to compare two files and to create versions for a VM within VM or more.

If all this talk to someone I'm interested.

In advance thank you,


P.S : Sorry for my english Cool


Jan 12, 2012, 6:01 AM

Views: 1381
Re: [romain0412] Comparison and editing files script

I do not know how to compare two files and to create versions for a VM within VM or more.

Comparing two files and see whether they are different:

Unless the files are exorbitantly large, you could just read them into a strings and compare the strings. Alternatively you can use File::Compare from CPAN.

Your sentence create versions for a VM within VM or more is not English which I can understand. What is VM? Virtual Machine? Vamipire Murder? Most of all, what does it mean to create something "within VM or more"?

Maybe it would help if you are more specific with your question.


Jan 12, 2012, 6:08 AM

Views: 1380
Re: [romain0412] Comparison and editing files script

Im not sure what ur asking? U have a probelm with code u alrdy have or are u explaining ur idea and asking if its possible? depening on the readability of The source files will it be it be possible, I mean the files from the program r viewable to read and not obscure.