NAME|VALUE = a TASK|VALUE = copy CAPS|VALUE = 0 PKG_TYPE|VALUE = premium NAME|VALUE = z TASK|VALUE = cut CAPS|VALUE = 0 PKG_TYPE|VALUE = premium NAME|VALUE = c TASK|VALUE = paste STACK|VALUE = 2 SHIP|VALUE = lowtier #### CAPS|VALUE = PKG_TYPE|VALUE = #### use Tk; use IO::Handle; #################### Check for correct usage of script############################ $mw = new MainWindow; my $num_args = $#ARGV +1 ; if ($num_args != 0) { $mw -> messageBox(-message=>"\nUsage: perl replay_file_changes.pl\n"); exit; } ################################################################################## ###################### User input ################################################################# print "\nPLEASE SPECIFY INPUT FILE\n"; $ip_file = <>; chomp $ip_file ; #check validity of user input if (-e $ip_file){ } else{ $mw -> messageBox(-message=> "\n$ip_file IS NOT FOUND\n"); exit; } ################################################################################################## ###################### Real deal ################################################################# open(INPUT_FILE, "<$ip_file") || die "\n!!!ERROR OPENING INPUT FILE. EXITING SCRIPT!!!\n"; while(){ if ($_=~ /(.*) =\n/ ){ $mw -> messageBox(-message=> "\nFormat not correct on line $. of input file. Exiting script\n"); exit; } elsif ($_=~ /(.*) =\s+\n/ ){ $mw -> messageBox(-message=> "\nFormat not correct on line $. of input file. Exiting script\n"); exit; } elsif ($_=~ /(.*) = \s+(.*)/ ){ $mw -> messageBox(-message=> "\nFormat not correct on line $. of input file. Exiting script\n"); exit; } elsif ($_=~ /^NAME\|VALUE = (.*)/ ){ &check(); } } sub check { #print "\n$cell_name\n"; my $name= $1; chomp $name; while(){ if($_=~ /^TASK\|VALUE = (.*)/){ $task_value= $1; } elsif($_=~ /^(.*) = (.*)/){ $line=$_; } elsif($_=~ /^NAME\|VALUE = (.*)/){ exit; } print "\n$name $task_value $line\n"; } } #### a copy a copy CAPS|VALUE = 0 a copy PKG_TYPE|VALUE = premium a copy PKG_TYPE|VALUE = premium a copy NAME|VALUE = z a cut NAME|VALUE = z a cut CAPS|VALUE = 0 a cut PKG_TYPE|VALUE = premium a cut PKG_TYPE|VALUE = premium a cut NAME|VALUE = c a paste NAME|VALUE = c a paste STACK|VALUE = 2 a paste SHIP|VALUE = lowtier