How to Create Reports With Perl

Use Perl to create simple reports. Include a header with a title, page number and other important information. Perl tracks how many lines are in the report and makes a new page when needed. These reports are useful for reporting lots of data with a small text output. Create the reports using a free-form report or set a fixed format.

Instructions

    • 1

      Open your Perl application FORMAT.DAT file.

    • 2

      Enter open "(FILE, " @lines = ;
      close(FILE);." This sets the format for the report so that each entry is its own line.

    • 3

      Create the body of the Perl reports by giving Perl direction on what to report. Using a grocery list as an example, enter
      "for each (@lines) {
      chop;
      ($isle, $item, $price) = (split(/!/));
      print("Isle=$isle Item=$item Price=$price\n");
      }"

    • 4

      Use this format if the database items are all complete. If there are items missing, the format won't account for the missing items. See the example:
      Isle=5 Item= Price=
      Isle=2 Item=Oranges Price=0.32
      Isle=7 Item=Potato Chips Price=2.95
      Isle=9 Item=Light Bulbs Price=2.50

    • 5

      Write the list another way if you want a fixed-width format. Use the code
      "for each (@lines) {

      chop;

      ($isle, $item, $price) = (split(/!/));

      $isle = "" if !defined($isle); These lines assign null

      $item = "" if !defined($item); strings if no info is

      $price = "" if !defined($price); present in the record.

      print("Isle=$isle Item=$item Price=$price\n");

      }"

    • 6

      Output the created Perl reports similar to the following example:
      Isle=5 Item= Price=
      Isle=2 Item=Oranges Price=0.32
      Isle=7 Item=Potato Chips Price=2.95
      Isle=9 Item=Light Bulbs Price=2.50

Related Searches:

Resources

Comments

  • Tonyclav Aug 28, 2008
    Perl has a 'format' command which can be used to make sure report fields are aligned and formatted (e.g. as currency) correctly.
  • Tonyclav Aug 28, 2008
    Perl has a 'format' command which can be used to make sure report fields are aligned and formatted (e.g. as currency) correctly.

You May Also Like

  • Pearl Laser Vs. Pearl Fractional

    Pearl is the name given to several different skin-resurfacing laser therapies by Cutera, a company that markets and sells laser medical devices....

  • How to Make a Terminal Report Format

    Not all computer programs use graphical user interfaces (GUI), the colorful set of windows, screens and buttons that computer users have become...

  • How to Search for a File in Perl

    Perl comes with a File::Find module that allows a user to search for a file. The File::Find::find function descends into subdirectories and...

  • How to Generate PDF Files Using Oracle PL/SQL

    The Oracle PL/SQL language provides you with the programming tools to query and retrieve data. You can also use the Oracle language...

  • Pearl Diving in Australia

    Pearl diving in Australia has a rich history, dating back to simple aborigine diving and harvesting practices. Today, pearl divers use sophisticated...

  • Perl Tutorial for Printing HTML & Inline HTML Frames

    The Perl scripting language was designed to facilitate text manipulation and report processing. It features powerful regular expression capabilities, with a compact...

  • How to Embed Perl in HTML

    The convenience of embedding scripting code in HTML documents for web development is undeniable. Having a powerful language like Perl working just...

  • How to Delete a File in Perl

    Depending on the nature of the PERL program it may be necessary to delete files on disk. For example, if a blank...

  • How to Create Vertical Lines in Access Reports

    Microsoft Access is a relational database manager that allows you to build tables and forms that will compile to create a printable...

  • How to Create a Bridge for a TV News Report

    A bridge is a stand-up that falls in the middle of the reporter's package. It's a transition. A bridge can be used...

  • How to Design Access Reports

    Access reports have several sections including the report header, report footer, page header, page footer and detail. Each section of the report...

  • MySQL Perl DBI Tutorial

    One of the most powerful features of Perl is its ability to process, parse, manipulate and format text and data, making it...

  • MySQL Perl Tutorial

    Connecting to the MySQL database from a Perl script requires the Perl DBI and DBD:MySQL modules. These modules can be obtained from...

  • How to Zip Files Using Perl

    PERL is an interpreted scripting language popular with many system administrators for automating their jobs. It's core libraries contain functions for easily...

  • How to Hide Password Characters in STDIN Perl Windows

    Perl is a popular scripting language used by system administrators to automate processes on their computers. It's a powerful interface designed to...

  • How Can I Create a PDF Report with PL/SQL?

    PL/SQL is a language used in Oracle to request data in a specific format with specific information. If you're creating a report...

Related Ads

Featured