473,245 Members | 1,530 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,245 software developers and data experts.

Problem with Range Operator sequence number

I have the following code(excerpt) which grabs some lines from a
syslog
file and adds any found in the range to an array.

@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
foreach (@lines) {
push(@vvlines,$_) if /Volume vol[1-2] verification started/ ..
/Volume vol[1-2] verification ended/;
}

This piece of code is part of a foreach loop which iterates two times.
I have a problem with the following situation:

Pass 1 of the foreach finds the left side of the range but never finds
the right side. This means that the range operator is still true.

Pass 2 of the foreach now pushes all the lines onto the vvlines array
as the range operator is still true. This is not desired. I only want
to push the lines after the left side is matched.

How do I reset the range operator to false between each iteration of
the foreach loop ?

Many thanks.

Paul Porcelli
Jul 19 '05 #1
3 4490
Paul Porcelli <Pa***********@aggreko.co.uk> wrote in comp.lang.perl.misc:
I have the following code(excerpt) which grabs some lines from a
syslog
file and adds any found in the range to an array.

@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
foreach (@lines) {
push(@vvlines,$_) if /Volume vol[1-2] verification started/ ..
/Volume vol[1-2] verification ended/;
}

This piece of code is part of a foreach loop which iterates two times.
I have a problem with the following situation:

Pass 1 of the foreach finds the left side of the range but never finds
the right side. This means that the range operator is still true.

Pass 2 of the foreach now pushes all the lines onto the vvlines array
as the range operator is still true. This is not desired. I only want
to push the lines after the left side is matched.

How do I reset the range operator to false between each iteration of
the foreach loop ?


Make sure the second condition becomes true at the end of the file.
Untested:

/Volume vol[1-2] verification started/ ..
( /Volume vol[1-2] verification ended/ || eof);

The parentheses around the second operand may be unnecessary.

Anno
Jul 19 '05 #2
Paul Porcelli <Pa***********@aggreko.co.uk> wrote in comp.lang.perl.misc:
I have the following code(excerpt) which grabs some lines from a
syslog
file and adds any found in the range to an array.

@lines=();@vvlines=();
$t = new Net::Telnet (Timeout => 30, Prompt => '/<\d+\>/');
$t->open($t3);
$t->login($username, $passwd);
@lines=$t->cmd("tail -1000 syslog");
$t->close;
foreach (@lines) {
push(@vvlines,$_) if /Volume vol[1-2] verification started/ ..
/Volume vol[1-2] verification ended/;
}

This piece of code is part of a foreach loop which iterates two times.
I have a problem with the following situation:

Pass 1 of the foreach finds the left side of the range but never finds
the right side. This means that the range operator is still true.

Pass 2 of the foreach now pushes all the lines onto the vvlines array
as the range operator is still true. This is not desired. I only want
to push the lines after the left side is matched.
Your question would have been much clearer if yuo had actually *shown*
the outer loop, together with a set of data that throws ".." out of
sync.

The code you posted doesn't show your problem, so you got a few replies
that don't address your problem.
How do I reset the range operator to false between each iteration of
the foreach loop ?


Make sure the second condition becomes true at the end of the file.
Untested:

/Volume vol[1-2] verification started/ ..
( /Volume vol[1-2] verification ended/ || eof);

The parentheses around the second operand may be unnecessary.

Anno
Jul 19 '05 #3
On 15 Jul 2004 10:54:39 GMT, an******@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
Make sure the second condition becomes true at the end of the file.
Untested:

/Volume vol[1-2] verification started/ ..
( /Volume vol[1-2] verification ended/ || eof);

The parentheses around the second operand may be unnecessary.


They aren't, but this is definitely a time when expecting people to know
the difference in precedence is a Bad Idea.

--
Eric Amick
Columbia, MD
Jul 19 '05 #4

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

Similar topics

1
by: Paul Porcelli | last post by:
I have the following code(excerpt) which grabs some lines from a syslog file and adds any found in the range to an array. @lines=();@vvlines=(); $t = new Net::Telnet (Timeout => 30, Prompt =>...
2
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has...
3
by: Robert McGregor | last post by:
Hi there, I was wondering if anyone could help with this problem. I have a table with about 250,000 rows that relate to files that have been processed elsewhere in our business. Each file has...
4
by: Kamran K | last post by:
Hello I have created a client server application using C#. Existing application is using random number on client side to generate sequence numbers that are then assigned to transactions. This...
12
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ...
5
by: tojigneshshah | last post by:
Hi, How to restart sequence number once the data is imported/loaded into the tables? Please advise. regards Jignesh
1
by: ddice | last post by:
I need to update and then read a sequence number, but I think its failing when there are many users updating at the same time. Here's what I'm doing update datatable set nextnr = nextnr+1 where...
0
by: Mikelowe | last post by:
Would like to know is there an automated way to copy the maxvalue of sequence number from db2 production to db2 test. When we copy data from our production that uses a sequence number value as its...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
5
by: jazznojive | last post by:
I've created a textbox control on a userform and I am trying to figure out how to make the text populate to a worksheet range in sequence automatically. I've figued out how to get the text that the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.