|   
  |    
  | 
Perl has nine positional variables (similar to sed) that can be used for backward referencing matched sub-strings, as illustrated by the code in Listing C.16.
Listing C.16 wordSwitch1.pl
my($currentLine) = "one two"; if( $currentLine =~ /(\w+)\s+(\w+)/ ) {    print "original words: $1 $2\n";    print "switched words: $2 $1\n"; } 
You can launch the Perl script wordSwitch1.pl in Listing C.16 from the command line as follows,
perl -w wordSwitch1.pl
and the output is as follows:
original words: one two switched words: two one
|   
  |    
  |