Homework again? You can do both of these with the s/// operator, take a look at the examples in perldoc perlop, especially the "e" option.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
| [reply] [d/l] [select] |
You really, really should show us the code that you have tried, what it outputs, and what you expected it to generate so that we can see where you are having trouble. So far you make it appear that you have done no work of your own at all and I'm sure you wouldn't want to give that impression would you?
Remember when you post code here to use code tags.
Perl is Huffman encoded by design.
| [reply] |
HI man!! you hav asked us to suggest a solution.. But we can't help u without seeing the code you have built. Please go through the man pages for regular expressions and learn the concepts before proceeding with coding.
A perl Script without 'strict' is like a House without Roof; Both are not Safe;
| [reply] |
use strict;
use warnings;
my $input='CNNNTGNNTN';
if ($input eq 'CNNNTGNNTN') {
print "First answer:\tC-1TG-1T-1\n";
print "Second answer:\tC3TG2T1\n";
}
It may perhaps not be universally applicable, put it solves this particular case well.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] [d/l] |