#! /usr/bin/perl use strict; use warnings; unless ( open( FILE, "name_of_file" ) ) { die "Could not open file for reading\n"; } my %hash; while () { if ($_ =~ /^(maintenance_mode)\s([\w,=]*)$/) { $hash{$1} = $2; } }