We have moved to www.dataGenX.net, Keep Learning with us.

Saturday, September 22, 2012

Useful Perl Scripts : Part-1


1.   To Replace a character in a string


#!/usr/bin/perl

my $string = "This is string";
$string =~ tr/s/a/;
print $string;




2.   To convert the text from Upper to Lower


#!/usr/bin/perl

my $string = "THIS IS A STRING";
$string =~ tr/A-Z/a-z/;
print "output is : $string" ;

       (OR)

#!/usr/bin/perl

my $string = "THIS IS A STRING";
$l_string = lc($string);
print "Input is : $string" ;
print "output is : $l_string";


 

3.   To convert the text from Lower to Upper


#!/usr/bin/perl

my $string = "this is a string";
$string =~ tr/a-z/A-Z/;
print "output is : $string" ;

       (or)

#!/usr/bin/perl

my $string = "this is a string";
$u_string = uc($string);
print "Input is : $string" ;
print "output is : $u_string" ;


Keep looking this page for more script........


njoy the simplicity.......
Atul Singh

No comments :

Post a Comment