Using value fields to print output. : Field « Report « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » Report » Field 
Using value fields to print output.
   
#!/usr/local/bin/perl 

while ($line = <STDIN>) { 
   $line =~ s/[^aeiou]//g; 
   @vowels = split(//, $line); 
   foreach $vowel (@vowels) { 
      $vowelcount{$vowel+= 1
   

$~ = "VOWELFORMAT"
write; 

format VOWELFORMAT = 
----------------------------------------------------------- 
Number of vowels found in text file: 
a: @<<<<< e: @<<<<< 
$vowelcount{"a"}, $vowelcount{"e"
i: @<<<<< o: @<<<<< 
$vowelcount{"i"}, $vowelcount{"o"
u: @<<<<< 
$vowelcount{"u"
-----------------------------------------------------------



   
    
    
  
Related examples in the same category
1.Format Field Types
2.Multiline fields
3.Split a long field over multiple lines
4.Field Designator Symbols
5.Field Display Symbols
6.Different types of fields
7.Writes a string using the multiline field format.
8.Valid value-field formats.
9.Limitations of the @* value field.
10.A program that uses a value field that does formatting.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.