my $word; { # Memory is cheap...for some applications local $/ = undef; open( FILE, "< $file" ) or die( "Ack: $!" ); my $whole_file = ; close FILE; # Assume whitespace delimiting ( $word ) = $whole_file =~ /TARGET\s*=\s*(\S+)/; } # $word is now set to our value or undefined