John Doe <[EMAIL PROTECTED]> Wrote: : : Hello all, : i have problem, and i don't know where is my mistake.
Your first mistake is not describing the problem in your message. A good programmer realizes that help comes best if the problem is stated clearly. Your second mistake was not to include at least a partial listing of the source file ('sorted'). I had to make up a file to find out if your problem might have been in the regex. This slowed me down as I had to wonder if my guess about the file structure was correct. Your short answer, assuming I have guessed at the correct problem, is that you are not removing the line ending from $data before comparing it to each element of @myarra. : while ($data = <FILE>) { chomp $data; : $backupdata = $data; : $data =~ s/^(\S+)\.//g; Long answer: : --- : #!/usr/bin/perl strict and warnings enforce good programming practices. use strict; use warnings; : @myarra = ("test","error","block"); : $file = 'sorted'; # File contain records xxx.xxx.xxx Declare variables lexically using 'my'. 'myarra' is not very descriptive. Don't get bagged down on naming things, but avoid names like 'array' and 'hash'. They give no clue to others what the data represents. my @fields = qw/test error block/; my $file = 'sorted'; : # i need last symbols after last -> . : open(FILE, $file); How do you know it opened? Always test that a file opens properly. open FILE, $file or die qq|Cannot open file "$file": $!|; : while ($data = <FILE>) { chomp $data; : $backupdata = $data; : $data =~ s/^(\S+)\.//g; # Remove xxx.xxx. get last 2 : # or 3 symbols after last -> . : $data = lc($data); # make $data to lowercast Split would work without destroying the original: Also, $data is not very descriptive. Every input in computer programming is considered data. $line is a more common name for the lines in a file. I assumed the text you were retrieving was a field. Since $line is not destroyed in the code blow, it can be used in the report. while ( my $line = <FILE> ) { chomp $line; my $field = lc( ( split /\./, $line )[-1] ); : for ($i = 0; $i < 3; ++$i) I prefer: foreach my $i ( 0 .. 2 ) HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>