open my $FH, '<' , $config or die "Cannot open $config: $!\n"; my $data = <$FH>; # Dump the line $data = ''; while (<$FH>) { next if /^\s*#|^$/; $data .= $_; } close $FH; while ($data =~ m/\{([^}]*)\}/gx ) { print "$1\n"; }