K
ken
Okay, I thought this might be a problem that has been addressed, but
Google didn't lead me to anything. I have source code files with blocks
denoted by {}. For exapmle:
loop a1 {
cmd;
loop a2 {
cmd;
cmd;
}
}
loop b1 {
cmd;
...
}
I want hide to (or collapse) all code blocks at a depth > N.
For example, N=1 would collapse loops a1, a2, b1 and output:
loop a1 {}
loop b1 {}
N=2 would only collapse loop a2 in this example:
loop a1 {
cmd;
loop a2 {}
}
loop b1 {
cmd;
...
}
I'd like to get something where N is just a variable in the Perl script,
but for now I'm already stuck just trying to get the N=1 case.
#!/usr/bin/perl
undef $/;
while(<STDIN>) {
s/{.*}/{}/gms;
print;
}
I see why this does not work, but not sure how to proceed. Any help
would be appreciated. Thanks,
Ken
Google didn't lead me to anything. I have source code files with blocks
denoted by {}. For exapmle:
loop a1 {
cmd;
loop a2 {
cmd;
cmd;
}
}
loop b1 {
cmd;
...
}
I want hide to (or collapse) all code blocks at a depth > N.
For example, N=1 would collapse loops a1, a2, b1 and output:
loop a1 {}
loop b1 {}
N=2 would only collapse loop a2 in this example:
loop a1 {
cmd;
loop a2 {}
}
loop b1 {
cmd;
...
}
I'd like to get something where N is just a variable in the Perl script,
but for now I'm already stuck just trying to get the N=1 case.
#!/usr/bin/perl
undef $/;
while(<STDIN>) {
s/{.*}/{}/gms;
print;
}
I see why this does not work, but not sure how to proceed. Any help
would be appreciated. Thanks,
Ken