Greetings!
Ive been fumbling around with reading and writing linux config-files, especially reading out different user-input, using pattern matching etc. Im getting there, perl seems very user-friendly in that matter.
Only thing left to me is: how can i SELECTIVELY change (write) data in a text file?
Lets say i have a whatever.conf file eg. for network settings:
ETH='ETH0'
USER='burningrubber'
DEMAND=300
DNSTYPE=SERVER
Selectively reading out is no problem. But lets say the order in which the above mentioned parameters are set in the file changes (for whatever reason; there are config scripts that would just put the "user=" line below "DEMAND)
What i did until now was open the file for write, and "print FILE "line\n"; for every line, thus rewriting the complete file. Even as a rookie i imagine thats far from being pro or 7337-style ;-)
Is there a way to say "just change that-and-that line, and leave the rest unchanged"?
Greatful for every hint,
Subotai
Ive been fumbling around with reading and writing linux config-files, especially reading out different user-input, using pattern matching etc. Im getting there, perl seems very user-friendly in that matter.
Only thing left to me is: how can i SELECTIVELY change (write) data in a text file?
Lets say i have a whatever.conf file eg. for network settings:
ETH='ETH0'
USER='burningrubber'
DEMAND=300
DNSTYPE=SERVER
Selectively reading out is no problem. But lets say the order in which the above mentioned parameters are set in the file changes (for whatever reason; there are config scripts that would just put the "user=" line below "DEMAND)
What i did until now was open the file for write, and "print FILE "line\n"; for every line, thus rewriting the complete file. Even as a rookie i imagine thats far from being pro or 7337-style ;-)
Is there a way to say "just change that-and-that line, and leave the rest unchanged"?
Greatful for every hint,
Subotai