Jimmy Lantz wrote: >Hi, I have the following problem: >I need to read a file and search for a match according to the following >criterias: > > >$match = KIN213:; > >open(IN, "$file"); > >How do I match the line in the file ???? And set the text to var $titel ? > >close(IN); >} > >Below are some samples of lines in the file(the jidderish is supposed to >be random text and that's the text I need to set to the variabel $titel: > >OSH435: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf >KIN213: jfjfdshfjhsd this is a match jdhf >JAP346: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf >THA212: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf >KAN234: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf >KIN244: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf >KIN262: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf How about this: my ($titel); my $matchkey = "KIN123"; open(INFILE, "$file") or die("Can't open file $file for reading: $!\n"); while(<INFILE>) { chomp; my ($tomatch, $value) = split ": "; if ($tomatch == $matchkey) { $titel = $value; } } close(INFILE); Ricky ----- Pukku ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org