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"; } }