http://qs321.pair.com?node_id=11122044


in reply to Re: Need advice for perl use as awk replacement
in thread Need advice in for perl use as awk replacement

Thanks, me storing references is very interesting. At first I did not see exectely where your code does difeer to mine in that point, simply because I did not know the perl reference/value syntax. I was expecting a python like approach, but was wrong.

The interesting thing is that my script has \$1 .... which if I understand correctly would be references for python, but actually I user double quotes in th ebash script which requires me to pu \$1 to avoid $1 to be replaced by the shell. This I expect perl to see "$1,$2,$3..." without backslash, eg. value. Am I wrong here ?

The reason I use double quotes is that later thea ctual additional filtering conditions will be injected via shell variable depending on the bash function call arguments.

But I realize that actually my variable name for th earray "$m" was wrong and should be "@m". Cannot try now, but will give it a try tomorrow.

Replies are listed 'Best First'.
Re^3: Need advice for perl use as awk replacement
by hippo (Bishop) on Sep 22, 2020 at 08:34 UTC
    actually I user double quotes in th ebash script which requires me to pu \$1 to avoid $1 to be replaced by the shell

    Ah yes, you are quite right. I have to agree with brother jcb that using a one-liner for this, especially with double quotes, is just asking for trouble and will be a maintenance nightmare. Just put it all in a script and then you won't have to worry about escaping everything. Eventually, when you become more familiar with Perl and what it can do you may see the benefit in replacing all of the bash parts with Perl.

    There's a place for one-liners but this doesn't look like that place to me.


    🦛