> -----Original Message-----
> From: $Bill Luebkert
> Sent: Monday, July 25, 2005 11:42 PM
> 
> robert wrote:
> 
> >>s/"([^"]+) ([^"]+)"/$1\000$2/g;     
> > 
> > holy cow.  can you explain that substitution?   my brain just about
> > popped.
> 
> It's just replacing the blank/space between two words with a 
> binary 0 and losing the quotes.
 

yeah...  the quote/not-a-quote freaked me out because i 
thought quotes had to be escaped \"

anyhow, very cool...   i like it  :-)   



> Lyle didn't like that one cause it didn't handle mult spaces.
> 
> Here's another that handles mult spaces :
> 
> use strict;
> use warnings;
> 
> $_ = 'one "two  three" "four five  six" seven eight';
> 
> # you could call a sub rather than doing it all in the second half 
> # of the substitute ($tmp is because you can't modify $1).
> 
> s/"([^"]+ +[^"]+)"/my $tmp = $1; $tmp =~ s! !\000!g; sprintf $tmp/eg;
> 
> my @a = split / +/;
> foreach (@a) {
>       s/\000/ /g;
>       print "$_\n";
> }
> 
> That should make Lyle happy.
> 

well, it better.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to