just4spam
09-11-2003, 06:28 PM
I have a file that looks like this, here is the general format. PRIORITY, PATH, FILENAME, DESCRIPTION and USERNAME
priority path file description username
-----------------------------------------------------------
4 /home/my_home my_file1 d user1
2 /home/my_home my_file2 p user9
1 /home/my_home my_file3 p user7
3 /home/my_home my_file4 d user10
Now I have started writing this yet. I am looking for ideas. In the end I will write a program that will open this file every 60 seconds of so and orders the contnets based on the priority and write a new file that will look this this.
priority path file description username
-----------------------------------------------------------
1 /home/my_home my_file3 p user7
2 /home/my_home my_file2 p user9
3 /home/my_home my_file4 d user10
4 /home/my_home my_file1 d user1
Here is what I am thinking.
# open original file read one line at a time
# create a hash with the priority being the $key and the rest of the line being the $value.
# Comapre the $keys in the hash order then numberically
# write file with $key followed by $value.
I also thought about creating a array of arrays and compare there.
Any thoughts,
priority path file description username
-----------------------------------------------------------
4 /home/my_home my_file1 d user1
2 /home/my_home my_file2 p user9
1 /home/my_home my_file3 p user7
3 /home/my_home my_file4 d user10
Now I have started writing this yet. I am looking for ideas. In the end I will write a program that will open this file every 60 seconds of so and orders the contnets based on the priority and write a new file that will look this this.
priority path file description username
-----------------------------------------------------------
1 /home/my_home my_file3 p user7
2 /home/my_home my_file2 p user9
3 /home/my_home my_file4 d user10
4 /home/my_home my_file1 d user1
Here is what I am thinking.
# open original file read one line at a time
# create a hash with the priority being the $key and the rest of the line being the $value.
# Comapre the $keys in the hash order then numberically
# write file with $key followed by $value.
I also thought about creating a array of arrays and compare there.
Any thoughts,