PERL Vs. SED

PERL Vs. SED thumbnail
Perl and sed originated as UNIX text processing utilities

In its early days, the UNIX operating system was part of a text processing system developed at Bell Labs. The designers of UNIX wrote a collection of small, but powerful utilities to format and edit text documents, generate reports and print the results. Sed and Perl were utilities developed later to automate text processing by adding expanded programming language features to UNIX shell scripts. Both sed and Perl are powerful tools in the hands of an experienced programmer.

  1. Sed Overview

    • Sed is a UNIX operating system command line utility for editing text files. The name sed is the acronym for "stream editor." Like many other UNIX, BSD and Linux utilities, sed accepts and processes information piped or "streamed" to it from other applications. Sed commands formatted as regular expressions can search for, display, add or remove text from files. Sed can work on one file at a time or many in batches. Sed follows the UNIX philosophy of the small, powerful utility that performs one task very well.

    Perl Overview

    • Perl is a general-use, interpreted scripting language created in 1987 by Larry Wall. Originally named after the gem, Perl is now an acronym for "Practical Extraction and Report Language." Perl is a high-level language that borrows some syntax from the UNIX utilities sed and awk, as well as the C programming language. Current versions of Perl can be used as a command shell language or as a scripting language to build Web applications, access databases, create reports or manipulate text files. Perl has been used to build blogging software, online learning systems and even desktop applications.

    Similarities

    • Sed and Perl are both programming languages, but they differ in the depth and breadth of their features and applicability. Both are interpreted rather than compiled languages. Both sed and Perl commands can work on the command line or execute from scripts saved as text files. Both use regular expressions to parse and modify text files. Both have a concise, terse syntax that may flummox programmers used to high-level languages like C, C++, Python or Java. While both languages were developed on UNIX and UNIX-like operation systems, versions also exist for Windows systems as well.

    Differences

    • Sed's forte and reason to be is text processing. Perl adds to sed's strengths the tools and language features needed to create any application that doesn't depend upon speed or low-level system and hardware support. Sed has functional, but limited program flow branching that resembles the Basic and C goto statement. Perl has "if then" conditionals along with for, switch and while loops. Variables – symbolic names for information -- don't exist in sed. Perl, on the other hand, supports scalar variables, arrays and key-value pair hashes. Current versions of Perl even support types and object-oriented programming.

Related Searches:

References

Resources

  • Photo Credit Stockbyte/Stockbyte/Getty Images

Comments

Related Ads

Featured