Make Perl your embedded development tool

Source: Internet
Author: User
If you think Perl is just a tool for web developers, you need to rethink it now. It can also be part of your embedded programming tool.

If you think Perl is just a tool for web developers, you need to rethink it now. It can also be part of your embedded programming tool.

Perl is an advanced instruction language derived from C, sed, awk, and other programming languages. It is good at text processing, which is why it is popular in web site content processing.

However, as software developers, they also need to process text every day: source code, header files, makefiles, ing files, batch files, together with/connector error information, private file pattern, and so on.

Perl can be used as a complex search and exchange engine, a text processing and extraction tool, and a collection of batch processing files. It can combine internal tools with the programs you need to perform them flexibly.

You do not need to be a Perl expert either. Perl is relatively easy to learn and can be easily applied to many fields. Of course, if you want to learn more, there are still many things to learn, but it is not necessary. In particular, object-oriented features and many Perl functional modules are built on your sophisticated Foundation.

In addition to basic language structures, such as statements, control branches, variables, arrays, and hash tables, you need to be familiar with regular expressions to truly use most powerful text processing tools.

Regular expressions are equivalent to the minimum "programming language" stored in strings ". For an unknown, it is like a spell. But don't be fooled by it. Regular expressions only encapsulate a large number of character production and processing logic in a small space.

Let's take a look at some methods for applying Perl in embedded software development.

Remove Hardware definitions from data tables

For large semiconductor devices, it takes a long time to manually translate the storage device from the data table and the header files undefined to the software. If the document is in a PDF format, the coherent part is output into a text file, and then the Perl script is used to process the coherent hardware definition. This allows manual input of hundreds of lines of code to be saved, it is far more reliable than manual transcription.

From the # define header file in the C header file, the equivalent file in the natural assembler

The application of the Perl script can actively convert the C header file definition into equivalent files in the assembly code.

Process text output from private tools

Many embedded tools generate proprietary text patterns, and you need to transform them into other patterns of the target system. Perl is an excellent tool for dealing with such things ..

Data table computing

Using Perl's rich arithmetic modules, you can quickly find tables in the computing source code.

Statistical analysis of governance projects

When managing a large project, the code statistics are very useful for the project progress. These useful information includes the number of lines of code, the proportion of comments, and the number of ROM applications. The application Perl can actively obtain this information and participate in a text database to form the project history.

Analyze the connector ing file

 

Perl can read, sort, and filter the ing files generated by linker to obtain the target memory application information and optimize the results.

Convert a binary file to a data table

Although Perl is good at text processing, it can hold raw binary data. By applying this feature, you can convert binary files into tables or structures and embed them into your source code.

Code porting

During a project, I need to bring a large number of existing code to a new embedded platform. The target device lacks many system functions, and the target code cannot be born. the connector reports thousands of "unknown functions" error messages. I plan to rewrite the code, at least compile and connect successfully, which takes quite some time.

Perl solution: a simple Perl script extracts the name of the missing function from the error information file and finds the definition prototype of these functions from dozens of header files. Create a false version of these functions in the C file. One or two hours later, the transplanted code is connected to the new device, and the missing functions have been supplemented. The Perl script only uses 38 lines of code and saves a lot of time.

This is just a small example. Perl is only limited by your thinking. You can put Perl in your software development toolbox and try again.

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.