Removing the duplicate characters from the string:
#!F:\Perl\bin\perl -w
use strict;
#Removing the duplicate characters ('c' , 'd') but not ('e') from the string
my $val = 'abcccdddddeeeeeeeeeeeeecccccc';
print "\n Given String:", $val;
$val =~ y/cd//s; # 'y' is nothing but 'tr'
print "\nAfter :$val\n";
#!F:\Perl\bin\perl -w
use strict;
#Removing the duplicate characters ('c' , 'd') but not ('e') from the string
my $val = 'abcccdddddeeeeeeeeeeeeecccccc';
print "\n Given String:", $val;
$val =~ y/cd//s; # 'y' is nothing but 'tr'
print "\nAfter :$val\n";
No comments:
Post a Comment