Quote:
Originally Posted by era
I don't think I have captured all your requirements correctly but at least it's a start. If I am allowed to guess, what would be easiest is collect the output in a variable and print it after you have seen *Main End and printed out the line which immediately preceded it.
|
I tried almost all way using next , redo and last command in
perl , But I can't get these syntax correctly in
perl. I know its easy ,but still I cant find the efficient way using while and next statement in
perl.
I am trying to do the follwoing in
perl
Code:
nawk ' {
if($0 ~ /^\*Main Start/){
while( $0 !~ /^\*Main End/){
print $0;
getline;
}
}
} ' my.txt
One more code I want to do it in
perl pls give me some basic idea how to do it without creating any temporary files ..
Code:
TMP=/tmp/my_tmp$$
nawk '
/\*Main End/{
split(x,arr,",")
print "Loop " arr[1]
};
{x=$0
}
' my.txt > $TMP
nawk '{
if($0 ~ /^Loop/){
loop = $2
next;
}
if($0 ~ /^\*Main Start/){
printf "\nrepeat ("
print loop
} ' $TMP $my.txt
Thanks & Regards,
user_prady