Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
go ahead... be a heretic
 
PerlMonks  

Re: Scalar joining, concatenation, involving varying text

by davidrw (Prior)
on Jun 27, 2005 at 16:18 UTC ( [id://470374]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Scalar joining, concatenation, involving varying text

well, can use eval:
my $combined = join ' ', grep $_, map { my $value = eval "\$$_"; $valu +e ? sprintf("%s=%s", $_, $value) : undef } ( 'a' .. 'z' );
But comes with all the caveats of eval'ing arbitrary variables. I hope someone posted a way of doing this, which would make the map a lot simpler:
my $x = 3; print f($x); # 'x'
Also note that it is bad to use $a and $b becaues it can/will cause confusion with the special variables used by sort.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://470374]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.