Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Embed Perl scripting in C applications

How to add a scriptable element quickly and painlessly

Martin C. Brown, Writer and consultant, 自由职业者
Martin C. Brown is a former IT Director with experience in cross-platform integration. A keen developer, he has produced dynamic sites for blue-chip customers, including HP and Oracle, and is the Technical Director of Foodware.net. Now a freelance writer and consultant, MC (as he is better known) works closely with Microsoft as an SME, is the LAMP Technologies Editor for LinuxWorld magazine, is a core member of the AnswerSquad.com team, and has written several books on topics as diverse as Microsoft certification, iMacs, and open source programming. Despite his best attempts, he remains a regular and voracious programmer on many platforms and numerous environments. Contact MC at questions@mcslp.com or through his Web site.

Summary:  Have you ever wanted a quick way to add a scriptable element to your applications? Embedding an existing language into your application is the simplest and most effective way to incorporate such a system. You get the benefits of an established language to expand the functionality of your application in a flexible way without users having to rebuild the application to use it. This tutorial shows you how to embed a scripting language into an application. You see how to build the application and how to provide wrapper functions with full argument and return value support.

Date:  15 Dec 2004
Level:  Advanced PDF:  A4 and Letter (84 KB | 22 pages)Get Adobe® Reader®

Activity:  14546 views
Comments:  

Before you start

About this tutorial

Have you ever encountered an application or system that required access to a scriptable environment or component? One obvious reason for such a requirement is to make use of functionality provided by a scripting language that would be difficult or complex to achieve with C. The Perl language is an ideal candidate for tasks such as text processing, parsing, and reformatting. Perl is a practical and easy-to-use scripting language that has the advantage of a rich and well-designed application program interface (API) that enables the language to integrate with host applications.

This tutorial covers:

  • How Perl works
  • Perl data types
  • Embedding the interpreter
  • Running Perl scripts within your application
  • Exposing your application to the Perl scripts

Prerequisites

This tutorial is written for developers who want to know how to incorporate the Perl interpreter into applications and how to expose these applications to allow Perl to control and manage the components. To use the techniques in this tutorial, you must be proficient in C and have at least a basic knowledge of Perl, its structure, and how to write basic applications in the Perl language.

To run the code samples in this tutorial, you'll need:

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux, Open source
ArticleID=132997
TutorialTitle=Embed Perl scripting in C applications
publish-date=12152004
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.