http://www.perlmonks.org?node_id=988720


in reply to Re: Editing the contents of a variable
in thread Editing the contents of a variable

ww,

Just a thought, if the 'string-to-capture' had information separated by spaces, your code would eliminate all spaces, maybe the special case:

my $str = "yada yada <name> string-to-capture string-to-capture2 </n +ame> foo bar baz"; if ( $str =~ m!<name>(.*?)<\/name>! ) { my $var1=$1; $var1 = join(" ", split " ", $var1 ); # remove leading, trailin +g and # collapse internal white +space print "$var1\n"; }
would be better. ( Taken from Camel book 3rd edition, page 154 )

"Well done is better than well said." - Benjamin Franklin