Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Spliting letters in a string

by KM (Priest)
on May 08, 2001 at 00:53 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://78650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found