I have been able to pull the \n. That hasn't been the issue. My problem is that I need to build a perl script to add users to a group file for apache access. I am limiting access on different parts of the website via .htaccess and don't want to manually input each user that is added. Here is an example of the groups file:
users: testing tonyc timmah
admin: forceadmin useradmin
secure: secureuser cartman
What I need to be able to do is take say the secure line and add a name to the end of it then add the \n back in. I know I can break each group down with some form of an if/then statement. What I need to know is how to accomplish something along the lines of the following psudocode.
input user and group to add to
does user exist
if yes
exit script w/ error
else proceed
if group = user
remove \n
add user
insert \n
elseif group = admin
remove \n
add user
insert \n
else if group = secure
remove \n
add user
insert \n
The code must also be able to be redesigned into a script that will do the exact opposite of inserting. I need to be able to remove a user that could be listed anywhere on a single line.
The reason for my madness is that I am working on some add and remove user scripts that will add and remove users into the access conrols for a website from an administration page. I have that adding and removing portion working but I have to add scripts to make them add and remove users from the single group file similar to the one above.
Thanks for the help,
Ryan Sheskey