perl: conditionaly remove space

I want to remove all space NOT starting with http, the following works, but not elegant, is there better way?

$echo " a http  b" | perl -lne 's/\shttp/#http/g; s/\s+//g;  s/#http/ http/g; print $_;'
a httpb

Not able to understand exactly, but this may be the thing you want..

echo "a http b" | perl -lne 's/(http)\s+/$1/g; print'

The shortest I could get.

$ echo " a http  b" | perl -ple 's/\s(?!http)//g'
a httpb

great that is what I need delete all space except those before http.

Can you explain the usage of "?!", I googled but still couldn't understand it.

Got it:
http://www.perl.com/doc/manual/html/pod/perlre.html

Congratulations on finding the answer. Zero-width assertions are a very valuable tool sometimes. Sadly, they're only available in Perl (except if someone can correct me on that).