On Mon, Mar 30, 2009 at 11:30, Chap Harrison <c...@pobox.com> wrote:
snip
> I've looked at the perldoc for Term::ReadLine and it's a little thin -
> mainly because it describes itself as being only a front-end to a variety of
> other packages.
snip

Yeah, you really need to look in Term::Readline::Gnu to find the features.

snip
>> (my $prompt = $rec{city}) =~ s/(?<!^)([A-Z])/ $1/g;
>> $prompt .= ", $rec{state} $rec{zip}";
>
> What is the above substitution doing?
snip

It is adding spaces before capital letters that are not at the
beginning of the string.  So "NewDurhamTwpMetro" becomes "New Durham
Twp Metro".  (?<!) is a negative zero width look behind[1].  If it
matches, then the match fails.  In the regex part for the substitution
it say (?<!^) this means that even though the N matches [A-Z] since it
is preceded by the beginning of the string (^) it doesn't match.  All
of the other capital letters are not at the beginning, so they match.

1. http://perldoc.perl.org/perlre.html#%27(?%3C!pattern)%27

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
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