Jump to content

  • Log In with Google      Sign In   
  • Create Account


awk in perl


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Jarwulf   Members   -  Reputation: 222

Like
0Likes
Like

Posted 04 April 2013 - 05:15 PM

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?



Sponsor:

#2 Ectara   Crossbones+   -  Reputation: 2826

Like
0Likes
Like

Posted 04 April 2013 - 05:19 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS