For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > Re: REGEXP removing - il- - -b-f and - il- - - - f









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: REGEXP removing - il- - -b-f and - il- - - - f
Jay Savage

2005-04-27, 3:56 pm

On 4/27/05, Ing. Branislav Gerzo <konfera@2ge.us> wrote:
> Jay Savage [JS], on Wednesday, April 27, 2005 at 10:26 (-0400)
> thoughtfully wrote the following:
>=20
> JS> If all you want is the last column, this is a really long way to go a=

bout it.
> JS> while (<V4> ) {
> JS> print (split)[7];
> JS> print "\n";
> JS> }
>=20
> (split)[-1] is better, not ?
>=20


That depends on where you think you're data is going to get corrupted.
If you think something might throw a space in the middle of one of
the the other colums (e.g. "s g F01010"), (split)[-1] will work
better. On the other hand, if you think your input may contain
something like this at you:

6 2005/02/28 22:47 180 100% -il-o-b----- sg F01005 !error:

you need to grab (split)[7]. For general use, I thinkit's basically
a matter of personal preference.

In this case, it probably doesn't really matter: He's done 2>&1 on
the piped open, so there's no way to predict when the buffers will be
flushed or where stderr will be inserted into stdin. some of the
input is going to be munged either way.

Jay
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com