473,378 Members | 1,146 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,378 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 4497
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
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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.