An example of the -a option. : Perl Command « Language Basics « 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 » Language Basics » Perl Command 
An example of the -a option.
  

#!/usr/local/bin/perl 

# This program is called with the -a and -n options. 
while ($F[0=~ /[^\d.]/) { 
    shift (@F)
    next if (!defined($F[0]))

print ("$F[0] $F[1]\n")

   
    
  
Related examples in the same category
1.A program that uses the -0 option.
2.A program that uses the -l option.
3.Edit files using the -i option.
4.The -c Switch checks the Perl syntax without actually executing the Perl commands
5.The -e switch executes Perl statements at the command line instead of from a script.
6.The -n Switch: print the contents of a file or search for a line that contains a particular pattern
7.The -w option passed to the perl command generates a warning about the code itself.
8.Using -e option to execute the perl statement
9.Using /e modifier to evaluate
10.Using the -n option.
11.Using two statements with -e option
12.Using variable with -e option
13.'#!/usr/bin/perl -w ' tells the perl command to turn on extra warnings with the -w option.
14.Perl can take its input from a file and send its output to a file using standard I/O redirection.
15.Executing the Script
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.