I have a text file with a name and IP on each line, sepparated by double bars (||) like this for example:
[tt]
userone||22.51.32.32
usertwo||192.32.32.*
userthree||32.35.*.*
userfour||24.32.62.323
[/tt]
For example. Anyway, when I read in the file, I use the code:
[tt]
my ($users,$ips);
while(<USRS>){
chomp $_;
($users,$ips) = split(/\|\|/, $_);
push(@Users, $users);
push(@IPs, $ips);
}
[/tt]
That would work fine - except the chomp doesn't remove the newline. I don't know why. It's as though there's a new line line there that is not recognised as one. The only way I can get it to "chomp" properly is to chop TWICE.
I figured it was something wrong with the file, but I've tried redoing it, I even used a separate script to save it with JUST \n's after each line, but it still won't work.
Any ideas? I'm kind of iffy about leaving two chops next to eachother like that. If for some reason the first one starts working right, then I'll lose a character I don't want to.
I've also tried s/\n// but it didn't work either. same result as chomp.
[tt]
userone||22.51.32.32
usertwo||192.32.32.*
userthree||32.35.*.*
userfour||24.32.62.323
[/tt]
For example. Anyway, when I read in the file, I use the code:
[tt]
my ($users,$ips);
while(<USRS>){
chomp $_;
($users,$ips) = split(/\|\|/, $_);
push(@Users, $users);
push(@IPs, $ips);
}
[/tt]
That would work fine - except the chomp doesn't remove the newline. I don't know why. It's as though there's a new line line there that is not recognised as one. The only way I can get it to "chomp" properly is to chop TWICE.
I figured it was something wrong with the file, but I've tried redoing it, I even used a separate script to save it with JUST \n's after each line, but it still won't work.
Any ideas? I'm kind of iffy about leaving two chops next to eachother like that. If for some reason the first one starts working right, then I'll lose a character I don't want to.
I've also tried s/\n// but it didn't work either. same result as chomp.