Currently I have a simple program that takes user input and checks it against a list of values in a .txt file.
when using windows it works fine (all records are delimited by a carriage return, I used the "chomp" function for this)
but, when I moved the .txt file to a linux platform the records dont seem to be delimited anymore.
Here is some of my sample data (id.txt).
11000101
11000109
11000112
11000115
11000127
11000132
11000138
11000139
11000212
11000215
11000216
here is a piece of my code:
############################################################
#opens the file and puts the contents into an array
open (DAT, "id.txt") or die("Could not open file!");
my@loginData = <DAT>;
close (DAT);
#checks the value entered by the user against the values in the array
foreach my$login (@loginData)
{
#ensures that the usernames are seperated in the txt file
#carriage return is the delimeter
chomp($login);
if (lc($login) eq lc($loginName))
{
print "Match"
}
}
print "No Match Found";
############################################################
using windows it will find a match...on linux it wont find anything (however if I make a file with a couple of test records in linux and physically enter the return at the end of the line it seems to work fine). Is there some special way to save the id.txt file to retain the properties it has in windows? Do I need to create a regular expression to detect the carriage return in linux?
Im sure the answer is simple, but my knowledge of linux is limited.
when using windows it works fine (all records are delimited by a carriage return, I used the "chomp" function for this)
but, when I moved the .txt file to a linux platform the records dont seem to be delimited anymore.
Here is some of my sample data (id.txt).
11000101
11000109
11000112
11000115
11000127
11000132
11000138
11000139
11000212
11000215
11000216
here is a piece of my code:
############################################################
#opens the file and puts the contents into an array
open (DAT, "id.txt") or die("Could not open file!");
my@loginData = <DAT>;
close (DAT);
#checks the value entered by the user against the values in the array
foreach my$login (@loginData)
{
#ensures that the usernames are seperated in the txt file
#carriage return is the delimeter
chomp($login);
if (lc($login) eq lc($loginName))
{
print "Match"
}
}
print "No Match Found";
############################################################
using windows it will find a match...on linux it wont find anything (however if I make a file with a couple of test records in linux and physically enter the return at the end of the line it seems to work fine). Is there some special way to save the id.txt file to retain the properties it has in windows? Do I need to create a regular expression to detect the carriage return in linux?
Im sure the answer is simple, but my knowledge of linux is limited.