Sign in to follow this  

awk in perl

This topic is 1713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

This topic is 1713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this