awk in perl

Started by
0 comments, last by Ectara 11 years, 1 month ago

Hi, I ran across this line in a perl file


system ("awk \'\$1 == \"$label\" && \$3 <= $apex && \$4 >= $apex\{print\}\' $reference >temp_marker_$name") ==0 or die "$0 failed to awk";

Does anyone have an idea of what its doing? It seems to be printing out if some comparisons are met is as far as I figure.

Also what is with a variable name like temp_marker_$name? Aren't scalar variables supposed to start with $ and not have them in the middle? What is the purpose of the slashes in the awk command?

Advertisement

The way it looks is that the backslashes are escaping characters that would be recognized as syntactically significant in perl, so that those characters are passed as-is to awk. As far as temp_marker_$name, it seems to be expanding the value of $name in-place where it is referred to in the string, sort of like Bash scripting. This would result in a name like temp_marker_foo, if $name is holding the value of "foo".

As far as the actual purpose of the awk command's arguments, someone else will have to answer.

This topic is closed to new replies.

Advertisement