[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Perl Scripting

The CodeWarrior Perl plug-in implements Perl scripting functionality in the IDE. This plug-in takes advantage of the application programming interface (API) of the IDE.

The Perl plug-in operates as a compiler in the CodeWarrior build system. After you add a Perl script to your project and compile the project, CodeWarrior runs the Perl script.

Listing A.1 shows a sample Perl script:

Listing A.1 Perl Script Example


# Simple Perl Example
# Print a line of text
print "Hello World!\n";

$scale0 = 0;
$scale1 = 1;
$scale2 = 2.5;

# Create and open a file for output
open (theFile, ">output.txt");

# Dump some text into the file
print theFile "The file should now be open\n";
print theFile "Let's try a few things:\n\n";

# Arithmetic
print theFile "**Arithmetic \n";
print theFile $scale1 + $scale2 . "\n";
print theFile $scale1 * $scale2 . "\n";
print theFile $scale1 % $scale2 . "\n\n";

# Boolean logic
print theFile "**Boolean \n";
print theFile ($scale0 && $scale0) . "\n";
print theFile ($scale0 && $scale1) . "\n";
print theFile ($scale1 && $scale1) . "\n";

print theFile ($scale0 || $scale0) . "\n";
print theFile ($scale0 || $scale1) . "\n";

print theFile (!$scale0) . "\n\n";

# Comparison
print theFile "**Comparisons \n";
print theFile ($scale2 == $scale2) . "\n";

print "That's it, closing file\n";

# Close the file
close theFile;


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 02, 2000