Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: trying to convert from awk to perl

by Perl Mouse (Chaplain)
on Jan 09, 2006 at 22:52 UTC ( [id://522060]=note: print w/replies, xml ) Need Help??


in reply to trying to convert from awk to perl

The problem you are suffering from is that fact that the backticks are an interpolative context. Which means that the $1 you have is interpolated before the call to awk is made. And you have the same for the $0. Putting backslashes before the dollar signs will solve this problem.

However, it doesn't make sense to use backticks here. Backticks run the command, and return the output of the command - however, since your command redirects all output, there's nothing to collect. The following system command you make doesn't make sense - it executes nothing. You'd be better off to use system here, instead of the backticks - and then you can q and avoid $1 and $0 to be interpolated:

system q {awk '$1 ~ /^F/ {print $0 }' /tmp/frhtest/ADDC.bak > /tmp/frh +test/ADDC.}.$date; die "Command failed" if $?;
Perl --((8:>*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found