On 2010.07.09 21:57, Uri Guttman wrote:
>>>>>> "SB" == Steve Bertrand <st...@ipv6canada.com> writes:
> 
>   SB> On 2010.07.09 21:40, Uri Guttman wrote:
> 
>   >> what input? i see none there. but what you want is either -p or -n. both
>   >> are among the most useful options for perl oneliners. look them up in
>   >> perlrun and pick which one you want.
> 
>   SB>   | perl -p -e 's/.*\s+//'
> 
> you need to test that one liner all by itself by feeding it some of
> those lines. the regex is very wrong as it will delete the entire line
> and therefore print nothing. .* matches the whole line before the
> newline and \s+ matches the trailing newline. if you added the -l option
> too, it would strip the newline off before regex is run and likely will
> do what you want. but a better regex is needed. i gotta run so i can't
> help with that now.

Thanks for the help all, here's what I've come up with:

perl -pe 's/(.*?)\s+//'

...match the least amount possible before one or more spaces, and
replace everything up to the last space with nothing.

It now also works without -l, which removes the line ending before
processing, and then adds it back afterwards (per perldoc perlrun).

Apparently, the reason -l made my original regex work is because there
was no newline, so the \s+ stopped in the tab in between the output, and
didn't run until the end of the string, as Uri mentioned in his description.

Thanks everyone.

Steve


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to