Perl invokes the external Command (g) method of awk _perl

Source: Internet
Author: User
Tags perl script

However, the common gadget of the Linux system is inherently friendly to the columns, sometimes invoking awk directly in Perl is more convenient and efficient than writing the corresponding Perl script. For example, insert the AWK statement with system:

Copy Code code as follows:

System (Gawk ' {print $} ' $filename);

Execute the L statement, you will find that the line error, prompting you to use the Read-only variable $.
So how do you deal with the conflicts in two ecosystems?
There is a simple solution:

Copy Code code as follows:

My $i = "$";
System (gawk ' {print $i} ' $filename);

This solves the problem of (g) the conflict of the built-in variables of awk and Perl.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.