|
|
| "be consistent" | |
| PerlMonks |
Re: Assign value of SHELL COMMAND to a variable in PERLby ambrus (Abbot) |
| on Jul 12, 2012 at 07:08 UTC ( #981313=note: print w/ replies, xml ) | Need Help?? |
|
You must quote the dollar sign in the qx literal so that perl does not interpret it. Updates: The other mistake is that you don't remove the newline so "$status" eq "stopped" won't ever be true. But you should probably test for the service running anyway, not for it being stopped. And it might be easier to use a regex match instead of a string equality.
I wouldn't use awk either.
Btw, I kept running to interpolation mistakes with $1 when writing perl scripts driving gnuplot, because I'm both interpolating values computed in perl to the gnuplot commands and passing literal $1 thingies that gnuplot interprets as column number expressions.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||