473,385 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

read a paragraph via scrit?

I'd lile to read the following file and output everything from
'NetBIOS Name Table for Host 192.168.5.10' to the first occurance of
"----------------------------------------"

can perl do that? here is the file (long file but only the portion of
it is shown here)


----------------------------------------
data
data
----------------------------------------
NetBIOS Name Table for Host 192.168.5.11
lines1
line2

Adapter address: 00-00-00-00-00-00
----------------------------------------

NetBIOS Name Table for Host 192.168.5.10

Adapter address: 00-a8-34-35-c3-aa
----------------------------------------
more data
more data
----------------------------------------
Jul 19 '05 #1
3 3268
NNTP wrote:
I'd lile to read the following file and output everything from
'NetBIOS Name Table for Host 192.168.5.10' to the first occurance of
"----------------------------------------"

can perl do that?
sure, but can you do it?
here is the file (long file but only the portion of
it is shown here)


Read about perl slurp mode, and multi line matching.

You can also read the file line by line, setting a $state variabele to
zero before you start to read, and when you "see" the NetBIOS (see:
perldoc -f index), set $state to 1, and print the line, and every line
after if $state == 1, except when you "see" the ---- stuff. Then you set
the state back to 0.

--
John personal page: http://johnbokma.com/

Freelance Perl / Java developer available - http://castleamber.com/
Jul 19 '05 #2
joe
ne******@yahoo.com (NNTP) writes:
I'd lile to read the following file and output everything from
'NetBIOS Name Table for Host 192.168.5.10' to the first occurance of
"----------------------------------------"

can perl do that? here is the file (long file but only the portion of
it is shown here)


Sure, but awk is probably easier, and awk is more likely to be on any
given machine.

awk '/^NetBIOS Name Table/,/^----------------------------------------/' data

Joe
--
If people don't want to come out to the ballpark, nobody's going
to stop them.
- Yogi Berra
Jul 19 '05 #3
NNTP <ne******@yahoo.com> wrote in comp.lang.perl.misc:
I'd lile to read the following file and output everything from
'NetBIOS Name Table for Host 192.168.5.10' to the first occurance of
"----------------------------------------"

can perl do that? here is the file (long file but only the portion of
it is shown here)


----------------------------------------
data
data
----------------------------------------
NetBIOS Name Table for Host 192.168.5.11
lines1
line2

Adapter address: 00-00-00-00-00-00
----------------------------------------

NetBIOS Name Table for Host 192.168.5.10

Adapter address: 00-a8-34-35-c3-aa
----------------------------------------
more data
more data
----------------------------------------


Make the line of dashes the record terminator:

$/ = "----------------------------------------\n";
/\QNetBIOS Name Table for Host 192.168.5.10/ and print while <DATA>;

Anno
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anthony Liu | last post by:
I have a news corpus that looks like the following. I want to do a statistical survey of the words used in the news report per se. So, I must not consider those words in the XML tags. I know...
3
by: xscully | last post by:
Is there a way to force the user to read a textarea? Just like those 'agreements' that is used in a few offline instalation.. You have to scroll all the way down of the textarea and then the I...
19
by: Holger Hasselbach | last post by:
- The value of the object allocated by the malloc function is used (7.20.3.3). - The value of any bytes in a new object allocated by the realloc function beyond the size of the old object are used...
1
by: Jean-François Michaud | last post by:
Hello people, I was wondering how it I could implement keep with next logic on lines of text contained within a paragraph. I need to have at least 10 lines of text within a paragraph to be...
1
by: abhas59 | last post by:
hi friends, I want to serialize a System.Windows.Documents.Paragraph and for this I have written the following code in the application : mypara cust = new mypara(); Paragraph ph...
15
by: Yogi | last post by:
Hi there, I have a quick question. In my html document, I want to make a new paragraph whenever I have a blank line in the html source. Using <p> and </pevery time is kind of cumbersome (I want...
14
by: wshaer | last post by:
Hi all, I have an assignment and I need some help with it. This is the assignment // Research reports are often required to conform to a given standard such as APA or MLA. These standards...
3
by: gentsquash | last post by:
I'm trying to display a paragraph that has a centered phrase, such as this one, in the middle of the paragraph. An example is the section "End of semester project" on my course-page ...
6
by: Haines Brown | last post by:
I'm trying to resolve a contradictory situation in which I have rows going down a page, and each consists of two elements: to the left is a thumbnail image that is a hot link; to its right is a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.