in reply to Re^2: sh: -c: line 1: syntax error near unexpected token `|'
in thread sh: -c: line 1: syntax error near unexpected token `|'
Besides take a look at perlop. There is a section about quoting (and you should quote, what you are giving to the shell) stating about the command given in backticks: "How that string gets evaluated is entirely subject to the command interpreter on your system."
For example, when I try to run your code on my Ubuntu I am getting something like
#!/usr/bin/perl use strict; use warnings; my $cmd = "------------- Hello World ------------"; my $result = `echo $cmd | grep '\-\-\-\-'`; print $result . "\n";
grep: unknown option »----«
I am assuming however, that you don't really want to search a string in Perl that way (there are better ways), but to learn something about calling external commands.
|
|---|