Benson has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Replace a set of characters
by tirwhan (Abbot) on Oct 30, 2005 at 08:29 UTC

    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
Re: Replace a set of characters
by GrandFather (Saint) on Oct 30, 2005 at 09:04 UTC

    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.
Re: Replace a set of characters
by vishi83 (Pilgrim) on Oct 30, 2005 at 09:42 UTC

    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;
Re: Replace a set of characters
by CountZero (Bishop) on Oct 30, 2005 at 16:36 UTC
    A possible solution is:
    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