Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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


Comment on Re: Spliting letters in a string
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://78650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-07-13 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (245 votes), past polls