I want to simply take all of the characters until the end of the line, and place these in a variable. Here is a try which might explain it more:
open my $in, '<', 'in.txt';
$iteration = 0
while(<$in>){
chomp;
next if /^#|^$/; //Skip over lines starting with # or empty lines.
if($iteration==0) {
die "Error in file formatting!\n" unless /^Data1: [.]*/; //*****
my ($data1) = /Data[1]: ([.]*)/; //*****
$iteration++;
}
else if($iteration==1) {
die "Error in file formatting!\n" unless /^Data2: \d+/;
my ($data2) = /Data[2]: (\d+)/;
$iteration++;
}
else if($iteration==2) {
die "Error in file formatting!\n" unless /^Data3: \d+/;
my ($data3) = /Data[3]: (\d+)/;
$iteration=0;
}
}
In the first if statement inside the loop, this looks for the string "Data[1]: " at the beginning of the line, and now I want to take everything after that, and place it in a variable. So, spaces, punctuation, numbers, underscores, etc are all fine, but as soon as a new line comes, I want to move on to the next line in my loop so stop there (I want to stop at the end of the line).