I was trying to make the regexp to read the X,Y and Z values into the variables but couln't do that in just one pass so I had to make a WHILE loop. I tried with this variation of the regexp, but all I did was - the values are now in a different vars and I still need three passes per line to read X, Y and Z values :-/

Can comeone, please, help me with constructing the correct regexp? What I would like to do is:

To parse the text file row by the row and to read the X, Y and Z values into the separate variables. The '=' after the variable name is optional. The line number at the beginning of the line is optional.

Another problem with my code is:

In case I'd have the input in $1, $2 and $3 (e.g. $1 would contain 'X=12.34') the next step would be to extract just a value without the variable name and the '=' sign. If I would use something as:

Code

$1 =~ m/(\d+\.?\d+)/;

Then I'd lose the contents of the $2 and $3 :-/ So how to modify $x without altering $(x+1), $(x+2), ... ? Chupo_cro

Yes, that is correct. The '=' is optional and optional spaces are allowed after the X, Y, or Z. The text is in fact G-code. However, different CNC machines may use different syntax, hence the '=' is optional. The lines I made for the testing purposes are purposely made to reflect as many as possible allowed variations.

Quote

Given that X, Y and Z are not always in the same order, I would probably use three distinct regexes on each line of input.

I am sorry about the incorrect posts timestamps, I thought the Time Offset parameter in the Display Profile Settings is relative to GMT but seems it isn't. I am in the GMT+01 timezone, it is 4:45 am here at the moment, I've set the Time Offset to 1, but the parameter is wrong :-/Chupo_cro

I believe that time stamps on this site are kept in PST (GMT-8). Your profile only changes the way they are displayed on your computer. Try setting your profile to +9.

Aaahh :-)) It was a very stupid of me to think the wrong parameter would cause the wrong time stamp at the server. However, that would be true in the case of the news server + incorrent time while sending the article - the problem when using NNTP servers can be seen very often. Seems I spend too much time on the newsgroups :-)

The correct parameter for my timezone is +2 at the moment (because of the daylight saving).