Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
XP is just a number
 
PerlMonks  

Re: Scalar joining, concatenation, involving varying text

by graff (Chancellor)
on Jun 27, 2005 at 21:22 UTC ( [id://470439]=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

If you wanted to do this with map, here is one such approach. Note that I'm using "$i,$j,$k" -- I think it's a bad idea to use "$a" and "$b" as names for application data variables, because in Perl these names are used by the "sort" function.
my ($i, $j, $k) = (2, 0, 4); # make up some data values my $ltr = "i"; my $combined = join "", map { $_ &&= "$ltr=$_ "; $ltr++; ($_)? $_:"" } + ( $i, $j, $k ); print $combined, "\n";
But frankly, I would prefer to use a solution that puts the values into a hash and loops over the sorted hash keys, as suggested by some of the replies above. (That way, you can safely start at "a" if you want.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://470439]
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.