#! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; use diagnostics; # grab user input.. print "Enter the name of the file to read: "; my $filetoread = ; chomp($filetoread); print "Enter the name of the file to write: "; my $filetowrite = ; chomp($filetowrite); print "Enter the name of the output file: "; my $fileoutput = ; chomp($fileoutput); open my $readhandle, "<", $filetoread or die "Unable to read '$filetoread'"; open my $writehandle "+>", $filetowrite or die "Unable to write '$filetowrite'"; open my $outputhandle ">", $fileoutput or die "Unable to write '$fileoutput'"; while (<$readhandle>) { if ($_ =~ /^\s\s(\S+)*delay\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { print $writehandle $_; } } while(<$writehandle>) { my ( $set ) = m/^\s+(\S+)/; #get the first word my ( $name,$value ) = m/-name (\S+) (\S+)/; #get the name and value my ( $mode ) = m/mode == (\S+)\"/; #get the mode print "$mode $name $set $value\n"; } close $readhandle; close $writehandle;