472,959 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,959 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 3253
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.