inputfile: base { LOCATION:../set/projects/all/files } #### My code: my $fn="inputfile"; open ( my $fh, '<', $fn ) or die "Could not open file '$fn': $!"; while ( <$fh> ) { chomp; if (/^LOCATION:\s*(\S+)/) { $input_dir = $1; print $input_dir; } My output is as follows: ../set/projects/all/files expected one: /set/projects/all/files