Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: How to expand a string

by lima1 (Curate)
on Nov 29, 2007 at 15:42 UTC ( #653878=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to expand a string
in thread How to expand a string

use strict; use warnings; use Data::Dumper; my %replace = ( R => '{A,G}', S => '{C,G}', K => '{G,T}', ' ' => '_', ); my $s = 'KAG GTR CAG CTG AAG SAG TCA GG'; my @results; for my $base (keys %replace) { $s =~ s/$base/$replace{$base}/g; } push @results, $_ while glob $s; @results = map { s/_/ /g; $_ } @results;
Update: BrowserUK's solution. Credits to him.

Replies are listed 'Best First'.
Re^4: How to expand a string
by Anonymous Monk on Nov 29, 2007 at 16:57 UTC
    Genius!! Anything I'd have written would have been considerably longer! Thanks very much.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2021-04-18 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?