in reply to storing grep output to variable

You are mixing Perl and a utility program in an odd way. Your example looks like it's trying to feed grep a slurp, and you want the file name, not the file contents. Either try:

my $output = `/usr/bin/grep "$prop" /path/to/file`;
Or try applying a regular expression to the contents of the file using only Perl.

Replies are listed 'Best First'.
Re^2: storing grep output to variable
by Anonymous Monk on Jun 08, 2004 at 16:02 UTC
    I could easily be doing something very odd - I only started learning Perl a few days ago. Is grep not a Perl function?
    What I am trying to do is to retrieve the line of my file that contains the variable $prop, which is fed in on the command line, and store that entire line in a variable. When I try implementing the code that pelagic sent, I get the entire file output, instead of just the one line I want - odd since the input string is unique.

      Yes, grep is a Perl function, but you are doing this:

      `grep ...`
      and the backtick operators invoke a shell to run grep, which is also a Unix system utility.