Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Spliting letters in a string

by KM (Priest)
on May 08, 2001 at 00:53 UTC ( #78650=note: print w/replies, xml ) Need Help??


in reply to Spliting letters in a string

I would do this with a hash:

#!/usr/bin/perl -w my $str = "abcdefg"; my %hash; %hash = map {$_ => $_} split //, $str; print qq{$_ => $hash{$_}\n} for sort keys %hash;

When run:

# ./t.pl a => a b => b c => c d => d e => e f => f g => g

Cheers,
KM

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://78650]
help
Chatterbox?
LanX starts googling the punch line ...
[choroba]: suddenly, a weird noise can be heard, and the conductor stops them
[choroba]: (sorry, was interrupted by a call)
[choroba]: What was that? asks he
[choroba]: and the triangle player says, "That was me. It's written here in the score"
[choroba]: and shows a bar with a note "ohne Triangel"
[choroba]: where "ohne" means "will bend" in Czech
[LanX]: one-day-the- triangle-player-of -an-orchestra-gets -very-sick xD
[choroba]: :)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-03-27 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.