areyouready344
asked on
how to insert a line in a multiline data record under an if condition in a search and replace regular expression?
For example, I have the following muliline data record which shows the hardware type but some don't show this information and need an if condition in a search and replace (in a regular expression) to check for this this condition and if
__Data__
@test_scsi`
memory_test
windows(xp)
hardware-type - hp
1. dkdjkdkdkdkdkdkdkd
2. dkdkdkdkdkdkdkdkdkdkk
And this example, the hardware type is not missing below the line of the Operating System but need an if condition to insert it in a search and replace Perl regular expression with a default of underfined hardware type
__Data__
@test_scsi`
memory_test
windows(xp)
Underfined Hardware type <-------------- missing and these words need to be added
1. dkdjkdkdkdkdkdkdkd
2. dkdkdkdkdkdkdkdkdkdkk
__Data__
@test_scsi`
memory_test
windows(xp)
hardware-type - hp
1. dkdjkdkdkdkdkdkdkd
2. dkdkdkdkdkdkdkdkdkdkk
And this example, the hardware type is not missing below the line of the Operating System but need an if condition to insert it in a search and replace Perl regular expression with a default of underfined hardware type
__Data__
@test_scsi`
memory_test
windows(xp)
Underfined Hardware type <-------------- missing and these words need to be added
1. dkdjkdkdkdkdkdkdkd
2. dkdkdkdkdkdkdkdkdkdkk
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thanks wilcoxon, your code is working as requested...
You need to add the following before line 9 somewhere...
my $os = '(?:windows|linux|mac)';