in reply to splitting contents of a variable ( not what you think!! )
Reading that complicated line from bottom to top... First we split the string into pieces, then we map those pieces to the new format, finally we join them together with a new delimiter.#!/usr/bin/perl -wT use strict; my $input = "word+word+word"; my $i=1; my $string = join '&', map {"keyword".$i++."=$_"} split /\+/, $input; print "$string\n"; __END__ keyword1=word&keyword2=word&keyword3=word
Update: Just for kicks... this regex seems to work as well:
my $i = ''; (my $string = $input) =~ s/(^|\+)/($i++&&'&')."keyword$i="/ge;
-Blake
|
|---|