Can someone please help me out with what I am doing wrong here, been scratching my head for a bit. I don't know much perl just making a small change to a irssi script.
$selectedname = <STDIN>; $Nameslist = `grep -i -w '$selectedname'~/file`;
It is working correctly the issue I am having is it looks like the variable isn't being inserted correctly. For example if I type in the same command using the word test in the command line I get 3 lines that show up. But if I use the same word with this script it comes up empty.
I know it is working correctly because I can do * as an input and it will show me the whole file. It is just not working with the inputed strings.
Any help would be much appreciated this has really been stumping me.
Actually when you are using <STDIN>
, a new line character is coming. so you need to remove the new line character. you can use chomp to remove the new line character
Code:
$selectedname = <STDIN>;
chomp($selectedname);
$Nameslist = `grep -i -w '$selectedname'~/file`;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With