Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to expand a string

by tcf03 (Deacon)
on Nov 29, 2007 at 15:46 UTC ( #653883=note: print w/replies, xml ) Need Help??


in reply to How to expand a string

Simplistically:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $string = 'RAGGTS'; my @temp; my @wanted; if ( grep /R/, $string ) { my $orig = $string; $string =~ s/R/A/g; push @temp, $string; $string = $orig; $string =~ s/R/G/g; push @temp, $string; } for my $string_ (@temp) { if ( grep /S/, $string_ ) { my $orig = $string_; $string_ =~ s/S/C/g; push @wanted, $string_; $string_ = $orig; $string_ =~ s/S/G/g; push @wanted, $string_; } } print Dumper @itemb;

a recursive sub might make that a little cleaner though.

UPDATE

output is
$VAR1 = 'AAGGTC'; $VAR2 = 'AAGGTG'; $VAR3 = 'GAGGTC'; $VAR4 = 'GAGGTG';
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-28 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?