Re: Search and delete
by blindluke (Hermit) on Dec 15, 2014 at 23:36 UTC
|
Welcome to the Monastery.
Please, put the data part of your question in < code > tags, it's impossible to see the lines you are referring to. Look at the Writeup Formatting Tips to find out how to format your data and code.
Have you already tried something to match those lines? If yes, what went wrong?
| [reply] |
|
Hi,
Thanks, for getting back to me . This are the lines that I wanted to delete .
This is what I have tried after opening the File descriptor from my command output .
next if $row =~ /^unassigned\n\nOK$/;
Below are the lines to be deleted
<
unassigned
physicaldrive 7C:3:7 port 7C:box 3:bay 7 SAS 1 TB OK
physicaldrive 7C:3:8 port 7C:box 3:bay 8 SAS 1 TB OK
>
| [reply] |
|
Have you read my response? Please apply some basic formatting to your post, it's completely unreadable right now.
Can you see four lines in the following output?
asdfghjklqwertyuiop
And now?
asd
fghjkl
qwertyu
iop
You can always count on people willing to help you in the Monastery. Make it possible for them by not forcing them to guess what your question is.
| [reply] [d/l] |
|
|
|
|
|
Um, thats not code tags :) <code> code here </code>
| [reply] [d/l] |
|
unassigned -> line 1 to be matched
physicaldrive......OK -> line2
physicaldrive ...Ok -> line3
| [reply] |
Re: Search and delete
by ww (Archbishop) on Dec 15, 2014 at 23:57 UTC
|
Please, READ the directions on formatting: they are prominently spelled out at the text_entry box where you created this gibberish. Alternately, READ and FOLLOW the guidance in Markup in the Monastery .
Without proper formatting -- ie, <c> an opening code tag and </c> an end code tag -- we cannot tell what you're asking, far less offer good help.
| [reply] [d/l] [select] |
Re: Search and delete
by 2teez (Vicar) on Dec 15, 2014 at 23:39 UTC
|
Hi,
Please post what you have done and where you are having issues with your code.
Also check this How do I post a question effectively?
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] |
Re: Search and delete
by Anonymous Monk on Dec 16, 2014 at 00:32 UTC
|
One problem with your program is /^unassigned\n\nOK$/ it can never match, you're reading line byline .. you're not reading two three lines at a time
Solution is simple, set a flag/counter of how many lines to skip
| [reply] [d/l] [select] |
|
Thanks for the prompt reply . That works for me.
Regards,
Praveen
| [reply] |
Re: Search and delete
by CountZero (Bishop) on Dec 16, 2014 at 07:18 UTC
|
It is not more difficult than this: use Modern::Perl qw '2014';
while (<DATA>) {
do { print; next } unless /^unassigned$/;
<DATA>;
<DATA>;
}
__DATA__
array A
physicaldrive 2C:1:1 port 2C:box 1:bay 1 SAS 1 TB OK
physicaldrive 2C:1:2 port 2C:box 1:bay 2 SAS 1 TB OK
array B
physicaldrive 2C:1:3 port 2C:box 1:bay 3 SAS 1 TB OK
physicaldrive 2C:1:4 port 2C:box 1:bay 4 SAS 1 TB OK
array C
physicaldrive 3C:1:5 port 3C:box 1:bay 5 SAS 1 TB OK
physicaldrive 3C:1:6 port 3C:box 1:bay 6 SAS 1 TB OK
array D
physicaldrive 3C:1:7 port 3C:box 1:bay 7 SAS 1 TB OK
physicaldrive 3C:1:8 port 3C:box 1:bay 8 SAS 1 TB OK
array E
physicaldrive 4C:2:1 port 4C:box 2:bay 1 SAS 1 TB OK
physicaldrive 4C:2:2 port 4C:box 2:bay 2 SAS 1 TB OK
array F
physicaldrive 4C:2:3 port 4C:box 2:bay 3 SAS 1 TB OK
physicaldrive 4C:2:4 port 4C:box 2:bay 4 SAS 1 TB OK
array G
physicaldrive 5C:2:5 port 5C:box 2:bay 5 SAS 1 TB OK
physicaldrive 5C:2:6 port 5C:box 2:bay 6 SAS 1 TB OK
array H
physicaldrive 5C:2:7 port 5C:box 2:bay 7 SAS 1 TB OK
physicaldrive 5C:2:8 port 5C:box 2:bay 8 SAS 1 TB OK
array I
physicaldrive 6C:3:1 port 6C:box 3:bay 1 SAS 1 TB OK
physicaldrive 6C:3:2 port 6C:box 3:bay 2 SAS 1 TB OK
array J
physicaldrive 6C:3:3 port 6C:box 3:bay 3 SAS 1 TB OK
physicaldrive 6C:3:4 port 6C:box 3:bay 4 SAS 1 TB OK
array K
physicaldrive 7C:3:5 port 7C:box 3:bay 5 SAS 1 TB OK
physicaldrive 7C:3:6 port 7C:box 3:bay 6 SAS 1 TB OK
unassigned
physicaldrive 7C:3:7 port 7C:box 3:bay 7 SAS 1 TB OK
physicaldrive 7C:3:8 port 7C:box 3:bay 8 SAS 1 TB OK
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James My blog: Imperial Deltronics
| [reply] [d/l] |
Re: Search and delete
by Anonymous Monk on Dec 15, 2014 at 23:42 UTC
|
| [reply] |