#!/usr/bin/perl -w use strict; $/ = undef; open (FILE, "< input.txt") or die $!; my $file = ; close FILE; # only standard stuff so far.. # this will hold the key's value my $value; # remove comments.. $file =~ s/;.*$//g; # check for the block we want if ($file =~ m/\*DESCRIPTION.+?\*END/s) { my $block = $&; # look for the keyword within the block if ($block =~ m/^$keyword\s*=\s*(.+)$/) { $value = $1; } else { $value = "Pattern not found, sorry"; } } else { $value = "Block not found.. Please check!"; } print $value . "\n";