Inputfile.txt is given file and output.txt is expected output in attachment.
In this situation we have to deal with nested case statements, which you can observe by seeing the input file and output given in attachment.
I got the output for one level nested case statement. first I saved the content between first "case" and last "esac" in a temp file and run the below given code.
I need your help and suggestion to get output for multiple nested case statement.
Thank you.
In this situation we have to deal with nested case statements, which you can observe by seeing the input file and output given in attachment.
I got the output for one level nested case statement. first I saved the content between first "case" and last "esac" in a temp file and run the below given code.
Code:
open (data,"<input.txt");
while (<data>) {
$para1; $para2;
unless (/case/../esac/){
if(/(.*)\)(.*)$/) {
$para1=$1;
$var=$2;
}
else { $var=$_; }
print $para1.$var."\n";
}
if (/case/../esac/) {
if(/(.*)\)(.*)$/) {
$para2=$1;
$var=$2;
}
else { $var=$_; }
print $para1.$para2.$var."\n";
} }
close data;
Thank you.
Comment