Thank you for taking the time to reply and suggest improvements. Taking them in order:
I have been trying to remember to use single quotes but I keep forgetting. I will keep working on that.
If I understand you right, I should do something like this:
Meaning that I don't use specific close PREF and close NEW_PREF commands.my $pref = "preferences"; my $new_pref = "preferences.tmp"; my $bak = "preferences.bak"; { my $pref = "preferences"; my $new_pref = "preferences.tmp"; my $bak = "preferences.bak"; open PREF, "< $pref"; open NEW_PREF, ">> $new_pref"; while (<PREF>) { s#$image_directory/.*#$wallpaper"#; print NEW_PREF $_; } rename ($pref,$bak); rename($new_pref,$pref); } chdir "/home/jivy" or die "Cannot change to jivy: ($!)"; if (`ps -e | grep icewm-session`) { exec "icewmbg -r"; } else { exec "icewm-session"; }
I had not seen the three-argument form of open but I looked it up after reading your post. That makes sense.
There is no extra tmp file hanging around. It is renamed to preferences in line 35. But I will do the suggested research for future use.
In reply to Re^2: Random Desktop Background for IceWM
by Texadan
in thread Random Desktop Background for IceWM
by Texadan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |