Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Editing the contents of a variable

by flexvault (Monsignor)
on Aug 21, 2012 at 12:58 UTC ( #988720=note: print w/replies, xml ) Need Help??

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


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

Replies are listed 'Best First'.
Re^3: Editing the contents of a variable
by ww (Archbishop) on Aug 21, 2012 at 18:07 UTC
    The s/ //g is OP's. Comment (question) is mine as, (for most purposes I can imagine in the background of the OP,) it makes no obvious sense.

    Your reply, however, calls attention to that, which is a good thing, if OP is cargo-culting or had missed the implications. + +

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988720]
[LanX]: oh they have sleper cells everywhere
[robby_dobby]: LanX: Not really, the only problems would be from religious divides. Coptics/Moslems/ Kurds/Jews
[erix]: Zzz
[erix]: Coptics? :)
[robby_dobby]: erix: Coptic Christians in Egypt
[choroba]: Robocoptic!
[erix]: I like Coptics :)
[LanX]: Copts
[erix]: sorry - just pulling your leg
[robby_dobby]: erix: It's a little late for that :-)

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (17)
As of 2017-04-24 16:10 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (442 votes). Check out past polls.