in reply to system bash return value
Just an example to be adapted to your specific needs:
Result:my $word = "banjo"; my $found_it = pseudo_bash_grep ($word, "words.txt"); print "Found $word in the words.txt file \n" if $found_it; sub pseudo_bash_grep { my ($keyword, $file) = @_; open my $FILE_IN, "<", $file or die "Failed to open $file $!"; while (<$FILE_IN>) { return 1 if /$keyword/; } return 0; }
$ perl search.pl Found banjo in the words.txt file
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: system bash return value
by haukex (Archbishop) on Dec 20, 2016 at 12:09 UTC | |
by Laurent_R (Canon) on Dec 20, 2016 at 14:49 UTC | |
by haukex (Archbishop) on Dec 20, 2016 at 15:08 UTC | |
|
Re^2: system bash return value
by shawnhcorey (Friar) on Dec 21, 2016 at 13:57 UTC | |
by Laurent_R (Canon) on Dec 21, 2016 at 18:08 UTC |