#finding @dh.nl #!/usr/bin/perl -w my $file="logs1"; chomp $file; open (FILE, $file) || die "Can't open logs file: $!\n"; my @line =(); chomp (@line); foreach (@line){ if (/(\D+)(@)(dh.nl)/) { $a=$1; $b=$2; $c=$3; } } print "$a"."$b"."$c"."\n"; close FILE;